Question: Apply Event - Driven Techniques to an Input Stream. Use FSAs ( epsi - NFAs, NFAs and / or DFAs ) to evaluate the
Apply EventDriven Techniques to an Input Stream.
Use FSAs epsi NFAs, NFAs andor DFAs to evaluate the inputs against for a given Regular Expression.
writing code to simulate a FSA based regular expression engine.
The system you develop will need to generate the FSA structures that match a given Regex dynamically and then evaluate several series' of inputs against that FSA to determine whether they are a match.
This assignment requires you to apply concepts and techniques covered in Chapters of the Notes on FSAs see course readings
You'll also need to document and thoroughly test your code using unit tests to ensure robust event handling techniques are being used.
The system will need to:
Parse an basic regular expression from standard input
Generate a epsi 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 below
ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING:
apt y install openjdkjdk junit
Your implementation must not use any of the programming language's inbuilt regular expression parsingevaluation librariesclasses
Your implementation may use any other librariesclasses available in the standard JDK and JUnit, but no other external librariesclasses
Your programs will be executed with the commands shown below:
Compiled 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 CtrlCThe program has output modes; a normal mode and verbose mode.
Verbose should trigger if the user adds a v when running the program see Software Requirements above
Under 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
