-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation
-
Scanner
a. General description
b. Algorithm
c. Automaton
-
Parser
a. General description
b. Automaton
-
Pretty-printer
a. General description
a. General description
Scanner job is to tokenize the SPL program into tokens defined by regular expressions:
< id, ….> - alpha (‘_’, alphaNum)*
< int, ….> - [-] (digit)+
< char, ….> \’ alpha \’
< op, ….> - ‘+’, ‘-‘, ‘*’, ‘/‘, ‘%’, ‘==‘, ‘<’, ‘>‘, ‘<=’, ‘>=‘, ‘!=’, ‘&&‘, ‘||’, ‘:’
< br, ….> - ‘(’, ‘)‘, ‘[’, ‘]‘, ‘{’, ‘}‘
< pnc, ….> - ‘,’, ‘;’
< fld, ….> - ‘.’
b. Algorithm
Symbols are being read one by one, added to string and changing state of the scanner automata. In the moment of transition from one final state k1 to another final state k2 where k1 is different than S, tuple <k1, string> is created and added to list of tokens. String is then cleared and algorithm follows until end of input.
c. Automaton
Automaton can be found here.
a. General description
Parser job is to create the Abstract Syntax Tree of a given program. Previously created token in scanner are now an input to parser.
b. Automaton
Parser automaton is created from modified version of original SPL grammar. For this language we have created the LL(0) parser. Modified grammar and other useful information for parser automaton can be found here.
a. General description Pretty printer goal is to create new version of user's program which is nicely formatted and free of comments.