This project is part of a larger project made for the course CS445 Compiler at Imam Mohammad Ibn Saud Islamic University. The goal of this program is to transform regular expression into a Deterministic-Finite Automata. Requires Java 11+.
- Download from releases.
- Place it anywhere on your computer.
- Run it through a console.
$ java -jar RE2DFA-{version}.jar "(a|b)*"
Tokens: [a, b, |, *]
NFA graph:
State{0,false}[2]
:-[null]->State{1,true}
:-[null]->State{2,false}
State{1,true}[0]
State{2,false}[2]
:-[null]->State{3,false}
:-[null]->State{4,false}
State{3,false}[1]
:-[a]->State{5,false}
State{4,false}[1]
:-[b]->State{6,false}
State{5,false}[1]
:-[null]->State{7,false}
State{6,false}[1]
:-[null]->State{7,false}
State{7,false}[2]
:-[null]->State{2,false}
:-[null]->State{1,true}
DFA graph:
0{Accept}:
:-[a]->1
:-[b]->2
1{Accept}:
:-[a]->1
:-[b]->2
2{Accept}:
:-[a]->1
:-[b]->2
NFA constructed with 8 states
Transformed into DFA with 3 states
You can also validate an input:
$ java -jar RE2DFA-{version}.jar "(a|b)*" aaaabbbaaba
Tokens: [a, b, |, *]
NFA graph:
State{0,false}[2]
:-[null]->State{1,true}
:-[null]->State{2,false}
State{1,true}[0]
State{2,false}[2]
:-[null]->State{3,false}
:-[null]->State{4,false}
State{3,false}[1]
:-[a]->State{5,false}
State{4,false}[1]
:-[b]->State{6,false}
State{5,false}[1]
:-[null]->State{7,false}
State{6,false}[1]
:-[null]->State{7,false}
State{7,false}[2]
:-[null]->State{2,false}
:-[null]->State{1,true}
DFA graph:
0{Accept}:
:-[a]->1
:-[b]->2
1{Accept}:
:-[a]->1
:-[b]->2
2{Accept}:
:-[a]->1
:-[b]->2
NFA constructed with 8 states
Transformed into DFA with 3 states
Regex: (a|b)*
Input: aaaabbbaaba is true
$ java -jar RE2DFA-{version}.jar "(a|b)*" -v
- \e for epsilon.
- \. for adding . as a character.
- Path animation for input.
- Minimizing DFA.
- Support for + and ? quantifiers.
- Overlap characters (see above picture).