Lexer for Stack Compiler
Lexical Structure
- Identifiers:
- [a-zA-Z][a-zA-Z0-9]*
- Constants:
- [0-9]+
- Punctuation:
- ; := ( )
- Operators:
- + - * = <> <
- Reserved words:
- mod div begin end if then else while do write writeln
Lexer DFA
Actually, this DFA is cheating a bit. For example, there should really be transitions from ASSIGN to each of the other states. Instead, in order to simplify the code, we transition back to START but don't absorb the next character, unless it is =.