Question: system will need to: Parse an basic regular expression from standard input Generate a - NFA to evaluate the regular expression Evaluate the subsequent inputs
system will need to:
Parse an basic regular expression from standard input
Generate a NFA to evaluate the regular expression
Evaluate the subsequent inputs against the regular expression.
Event Driven systems are particularly prone to errors so you'll also need to:
Document your planning of the system See LoggingDocumenting your Progress below
Write your own suite of test cases for your code See Testing your Code belowCompiled with
javac RegexEngine.java
Run with:
java RegexEngine
or for verbose mode
java RegexEngine v
Tests compiled with:
javac Test.java
Each Test run with:
java org.junit.runner.JUnitCore TestNameTest Your program will need to read input from the terminalcommand line's standard input Systemin
The expected input format is as follows:
abc
abc
ccc The input begins with the regular expression to test.
In this assignment, a regular expression can consist of lower and upper case letters, numbers, spaces, the alternation operator the Kleene star and Kleene plus operators and as well as brackets and
You are not expected to handle nested brackets.
Invalid input in this section should cause the program to print an error message and exit with an exit code of
The next section of input contains the input strings to evaluate against the regular expression.
Each string is on its own line; when a new line is entered, another string begins dont forget to reset states
A string can be emptyblank
A string can contain whitespace and other control characters.
This repeats until the program is terminated with a SIGTERM CtrlCUnder normal mode
After the user has entered the regex your program should print ready
Your program should then print true or false once for each input string provided as they are entered.
If the input string matches the regular expression, print true
If the input string does not match, print false
The input string should be evaluated for an exact match
ie the whole string from start to end must exactly match the regular expression to be accepted.
A string containing a match, but not exactly matching should print false.
Example user input is grey, output is highlighted pink
abc
ready
abc
false
ccc
true. Under verbose mode
After the user has entered the regex your program should print a transition table for the NFA generated followed by the word ready
The transition table does not have to exactly match the example below, but does need to reflect the NFA generated by your system;
this is for manual review and your own debugging.
Your program should begin to print true or false as the user enters the input strings for each character input including the initial state
If the system is currently in an accepting state, print true
Otherwise, print false
Hint: After a user has entered the input string the most recent output should match the normal output
Example user input is grey, output is highlighted pink
abc
epsilon a b c other
q qq
q qq
q q
q q
q q
q q
q q
q qq
q
ready
true
a
false
b
true
c
false
true
c
true
c
true
c
true
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
