a Grep like utility that utilizes NFAs (Nondeterministic Finite Automatas) and DFAs (Deterministic Finite Automatas).
This utility takes in a regex, and parses strings against the regex using a DFA which it creates on the fly. It also creates an NFA. (NOTE: NFAs use ~
to represent epsilon)
These DFAs are then used to test if a set of given strings match the original regex.
- Clone or download the main branch of the grepy repository.
- Inside of the downloaded files, you will find a folder titled "Production Version". This is where the working product is.
- In this directory, add your regex file in a
.txt
format. On the first line, write the regex you would like to use wrapped in a ^ and $ on either side. (ex.a+b
would look like^a+b$
). If you choose, you may also put strings to test on the next lines, one per line. For reference, refer to the other regex files which are in the folder already. - If you would like to specify the filenames of the outputted DFA and NFA, create the files using the extension
.DOT
. - Ensure that all of your files are in the "Production Version" directory before continuing.
- Before continuing, ensure that your computer is equipped with Java Runtime Environment and that it is accessible from your terminal of choice, as it will be necessary for continuing.
(hint: to check if you have it installed, type
java --version
to check.) - navigate to the "Production Version" directory within your terminal or command prompt.
- Start by typing the command
java -jar grepy.jar
, but do not press enter yet. - If you have created your own DFA and NFA files, add the DFA
.DOT
file name first followed by the NFA.DOT
file name. Finally add the file name of your regex.txt
file. - If you did not create DFA and NFA files, just add the regex
.txt
file. - So, your execution command will look like one of the two following commands:
- Once you run the command, the program will generate the state machines, as well as attempting to parse any strings that were in the regex file.
- you can choose to continue to try other strings by simply inputting them as specified by the interface, or typing
quit()
to end the program. - To view the state machines, the easiest way to create them would be to copy the contents of each file, and paste them into this site.