Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Documentation

Szymon Nakoneczny edited this page Mar 11, 2015 · 21 revisions

Content

  1. Scanner

    a. General description

    b. Algorithm

    c. Automaton

  2. Parser

    a. General description

    b. Automaton

  3. Pretty-printer

    a. General description

Scanner

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.

Parser

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.

Pretty printer

a. General description Pretty printer goal is to create new version of user's program which is nicely formatted and free of comments.

Clone this wiki locally