$30
Aims
Apply Event-Driven Techniques to an Input Stream.
Use FSAs (ε-NFAs, NFAs and/or DFAs) to evaluate the inputs against for a given Regular
Expression.
Overview
In this assignment, you will be 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 0-4 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.
Your Task
The system will need to:
1. Parse an basic regular expression from standard input
2. Generate a ε-NFA to evaluate the regular expression
3. Evaluate the subsequent inputs against the regular expression.
Event Driven systems are particularly prone to errors so you'll also need to:
1. Document your planning of the system (See Logging/Documenting your Progress
below)
2. Write your own suite of test cases for your code (See Testing your Code below)
11/10/2021, 15:25 Programming Assignment 1: Event Driven String Processing
https://myuni.adelaide.edu.au/courses/64843/assignments/238394 3/9
Programming Language/Software Requirements
Version Control System
Your work must be stored and submitted using GitHub
You will need to log your progress by commenting on your commits
Programming Language
You will need to use Java & JUnit to complete this assignment.
Your code will be run using JDK 11
Your test code will be run using JUnit 4
Your implementation must not use any of the programming language's inbuilt regular
expression parsing/evaluation libraries/classes.
Your implementation may use any other libraries/classes available in the standard JDK
and JUnit, but no other external libraries/classes.
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 TestName_Test
Input Format
Your program will need to read input from the terminal/command line's standard input
( System.in ).
The expected input format is as follows:
11/10/2021, 15:25 Programming Assignment 1: Event Driven String Processing
https://myuni.adelaide.edu.au/courses/64843/assignments/238394 4/9
(ab)*|c+
abc
ccc
1. 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 1.
2. 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
(don't forget to reset states)
A string can be empty/blank.
A string can contain whitespace and other control characters.
3. This repeats until the program is terminated with a SIGTERM (Ctrl-C).
Expected Output Format
The program has 2 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
i.e. 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)
(ab)*|c+
ready
abc
false
ccc
true
11/10/2021, 15:25 Programming Assignment 1: Event Driven String Processing
https://myuni.adelaide.edu.au/courses/64843/assignments/238394 5/9
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)
(ab)*|c+
epsilon a b c other
q0 q1,q5
q1 q2,q8
q2 q3
q3 q4
q4 q1
q5 q6
q6 q7
q7 q5,q8
*q8
ready
true
a
false
b
true
c
false
true
c
true
c
true
c
true
Submission, Assessment & Markin