-
Notifications
You must be signed in to change notification settings - Fork 0
The Parser Class for Pasring GrafState Syntax
NBKlepp edited this page Jun 13, 2018
·
7 revisions
While the GrafState syntax is much simpler to read and less cumbersome to write than the raw Scala code underneath the finite automata classes, the syntax is not directly legible to the Scala compiler. The parser object then translates between the GrafState syntax and the raw Scala code needed to generate the finite automata. The class is very simple, and contains just three methods.
The Parser class contains the following public methods:
- The constructor. The constructor takes no arguments.
- parseDFA : The parseDFA method takes as an input argument the path to a file containing the description of a DFA in GrafState syntax, and returns a DFA object upon successfully parsing the file. It should be noted that the parseDFA method may return a
SubmissionNotFound
exception if there is no file found at the path argument, as well as aParserError
exception if the description of the NFA in the file is not a valid description. That is, if it contains any invalid syntax, if any of the required pieces of the description are missing, if the start state is not a member of the set of states, if the set of accept states is not a subset of the set of states, if any pre-image defined for the transition function is not a member of the cross product of the set of states and the alphabet, or if any image defined for the transition function is not a member of the set of states. - parsenNFA: The parseNFA method behaves exactly like the parseDFA method, only it returns an NFA object instead of a DFA object.
Next up, take a look at the sample assignment, submission and solution sets to better understand the sample autograder provided in this repo.