This adds a class that matches regular expressions constructing an NFA and simulating it.
The basic idea is to transform the regex to "postfix" form which is equivalent to parsing and constructing the syntax tree for it. Once it's on postfix, you can process it left to right keeping a stack with the current NFAs built and when encountering an operator, proceed with the corresponding construction popping the needed operands from the stack (maybe just one in the case of kleene star, for example). To simplify stuff I just maintained a list of states and the stack contains the index of the initial and accepting state.
The simulation is then pretty simple just following the algorithm in the book.
Stuff missing:
allow . * | as input characters escaping them somehow (right now it will interpret those as the operators).
allow strings instead of single characters joined by concatenation. this can be done by pre-processing the string and adding some arbitrary character that could be interpreted as concatenation.
combine all the regex needed as flex does (section 3.8 in the book).
This adds a class that matches regular expressions constructing an NFA and simulating it.
The basic idea is to transform the regex to "postfix" form which is equivalent to parsing and constructing the syntax tree for it. Once it's on postfix, you can process it left to right keeping a stack with the current NFAs built and when encountering an operator, proceed with the corresponding construction popping the needed operands from the stack (maybe just one in the case of kleene star, for example). To simplify stuff I just maintained a list of states and the stack contains the index of the initial and accepting state.
The simulation is then pretty simple just following the algorithm in the book.
Stuff missing: