regex2dfa
Project description
regex2dfa
=========
[![Build Status](https://travis-ci.org/kpdyer/regex2dfa.svg?branch=master)](https://travis-ci.org/kpdyer/regex2dfa)
This is a command-line utility that converts a regular expression to a DFA.
* **input**: A perl-compatible regular expression, as defined by re2 [1].
* **output**: An AT&T DFA [2], which accepts an equivelent language to the input regular expression.
### References
* [1] https://code.google.com/p/re2/
* [2] https://openfst.org/
Building
--------
This utillity requires standard build tools: autoconf, make, gcc, etc.
Once you have your developement environment setup:
```
$ ./configure
$ make
$ ls bin/
regex2dfa
```
Example Usage
-------------
### Command-line
```
$ ./bin/regex2dfa -r "^(a|b)*$"
0 0 97 97
0 0 98 98
0
```
```
$ ./bin/regex2dfa -r "^(a|b)+$"
0 1 97 97
0 1 98 98
1 1 97 97
1 1 98 98
1
```
### C++ API
```C++
#include "regex2dfa.h"
...
std::string input_regex = "^(a|b)*$";
std::string minimized_dfa;
bool success = regex2dfa::Regex2Dfa(input_regex, &minimized_dfa);
std::cout << minimized_dfa << std::endl;
...
```
will output
```
0 0 97 97
0 0 98 98
0
```
=========
[![Build Status](https://travis-ci.org/kpdyer/regex2dfa.svg?branch=master)](https://travis-ci.org/kpdyer/regex2dfa)
This is a command-line utility that converts a regular expression to a DFA.
* **input**: A perl-compatible regular expression, as defined by re2 [1].
* **output**: An AT&T DFA [2], which accepts an equivelent language to the input regular expression.
### References
* [1] https://code.google.com/p/re2/
* [2] https://openfst.org/
Building
--------
This utillity requires standard build tools: autoconf, make, gcc, etc.
Once you have your developement environment setup:
```
$ ./configure
$ make
$ ls bin/
regex2dfa
```
Example Usage
-------------
### Command-line
```
$ ./bin/regex2dfa -r "^(a|b)*$"
0 0 97 97
0 0 98 98
0
```
```
$ ./bin/regex2dfa -r "^(a|b)+$"
0 1 97 97
0 1 98 98
1 1 97 97
1 1 98 98
1
```
### C++ API
```C++
#include "regex2dfa.h"
...
std::string input_regex = "^(a|b)*$";
std::string minimized_dfa;
bool success = regex2dfa::Regex2Dfa(input_regex, &minimized_dfa);
std::cout << minimized_dfa << std::endl;
...
```
will output
```
0 0 97 97
0 0 98 98
0
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
regex2dfa-0.1.9.tar.gz
(1.3 MB
view details)
File details
Details for the file regex2dfa-0.1.9.tar.gz
.
File metadata
- Download URL: regex2dfa-0.1.9.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | abcb4e710c917eddb6473591c8a4215709847016df437ca2cb1c096b8a0ddbc5 |
|
MD5 | fec44618d835c8203e8914baa1063db8 |
|
BLAKE2b-256 | fd68d5b86bb35ee1b5ec37a3b76e1fef107d948a72c5d1bdaa8f851d3175794a |