tokens) – Lex builds a function implementing a deterministic finite automaton to recognize regular expressions in linera time – Lex is able to read arbitrary input, and determine what each part of the input is. This is called 'Tokenizing'. • [1975] YACC (parser generator that uses LALR(1) via table-based bottom up parsing) – Parses stream of tokens • [1989] PCCTS (parser generator that uses LL(*)) that builds recursive descent parsers Aggelos Biboudis 2
only on the lexical and grammatical definition of the compiled language •Parser automatically builds the AST •AST nodes are strictly typed •Analysis is written in each own class •Analysis is separate from nodes Aggelos Biboudis 3
lexical definitions and the grammar 2. We launch the SableCC with the specification file as input 3. We create working classes 4. We create a main class to activate the lexer, parser and working classes 5. We compile everything with java compiler Aggelos Biboudis 4
destination root java package (where to put the generated files?) • Lexical definitions use regular expressions • Grammar is written in BNF Aggelos Biboudis 5
and analysis – Lexer and exceptions – Parser and exceptions – Node classes for a typed AST – Analysis contains one interface and three classes for AST walking Aggelos Biboudis 6