Implement a DFA simulator (in C, C++ or Python) in a Linux environment: Read in
ID: 3595751 • Letter: I
Question
Implement a DFA simulator (in C, C++ or Python) in a Linux environment:
Read in a specified machine (5-tuple definition) and process input strings against this DFA; output ACCEPT or NOT ACCEPT for each input string.
All error checking must be performed including command line argument parsing, valid definition file, valid input string etc.
Full help usage must be provided which should be self sufficient to run the program.
Input string is read from stdin which means following should work
./dfa -d m1.dfa <m1.in
./dfa -d m1.dfa <m1.in >m1.out
cat m1.in | ./dfa -d m1.dfa
-v option should provide verbose information on the working of the machine; for example display the definition of the machine, transitions as input is processed etc.
Deliverables
Source files
Sample Input/output
Define 3 machines: 1.6 b, c, f [Homework #2] and show at least 3 ACCEPT and 3 NOT
ACCEPT examples for each.
Define machine for a*.c—as done in class; show at least 3 ACCEPT and 3 NOT ACCEPT
examples
Sample Run
[The sample output below is my implementation and is provided as a reference; please feel free to change/improve this when you implement.]
Usage:
This is a simple DFA Implementation. The DFA definition
is specified via .dfa file; input string is read from stdin.
In nonverbose mode, print ACCEPT or NOT ACCEPT as the case may be.
Interactive Run:
Use of Pipe and Redirection for input:
Interactive Run with -v flag:
01 StartState: q1
FinalState:
Use of Pipe and Redirection for input with -v flag:
Alphabet: 01
Explanation / Answer
Code:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.