lexer → parser → parsed tree

Compared with AST, parsed tree is too verbose, for example, parsed tree will contain left bracket and right bracket (show all things in production rules). But for AST, since it knows that there would be a node represents method body, it will skip showing left and right brackets

COMP 512: Advanced Compiler Construction

Cooper: Engineering a Compiler, 2e Lecture Slides

Lexer:

regex → non-deterministic finite automator → deterministic finite automator → minimal DFA → Scanner

Untitled

RE to NFA

NFA to DFA

DFA to min DFA

visualize regular expression

Regulex:JavaScript Regular Expression Visualizer