December 2009
Intermediate to advanced
380 pages
9h 2m
English
| Pattern 24 | Syntax-Directed Interpreter |
This pattern directly executes source code without building an intermediate representation and without translating it to another language.
The sample implementation for this pattern focuses on building a syntax-directed interpreter for an SQL subset.
A syntax-directed interpreter mimics what we do when we trace source code manually. As we step through the code, we parse, validate, and execute instructions. Everything happens in the parser because a syntax-directed interpreter doesn’t create an AST or translate source code to bytecodes or machine code. The interpreter directly feeds off of syntax to execute statements.
The good news is that there are very few “moving parts” in a syntax-directed ...