Chapter 7 Revision: Parsers and Interpreters
Language execution pipelines bridge human-readable syntax and hardware computation. From lexical scanning and grammar-driven AST parsing to stack-based bytecode virtual machines and AST-transforming macro extenders, language frontends define how computational intent is realized.
Use these flashcards for active recall. Try to answer the question out loud before clicking the card to flip it.
Flashcards 🎴
What are the stages of a classic Language Execution Pipeline?
2. Syntax Analysis (Parser): Tokens → Abstract Syntax Tree (AST) matching a formal CFG.
3. Semantic Analysis: Scope resolution, type checking, and symbol table binding.
4. Intermediate Code Generation: AST → Linear Bytecode / SSA IR.
5. Execution / Optimization: Bytecode VM interpretation or JIT/AOT machine code compilation.
What is a Concrete Syntax Tree (Parse Tree) versus an Abstract Syntax Tree (AST)?
• Abstract Syntax Tree (AST): Structural, condensed hierarchical representation preserving only operators, operands, identifiers, and control structures necessary for evaluation.
What is the difference between LL(k) Top-Down and LR(k) Bottom-Up parsers?
• LR(k): Left-to-right scan, constructing Rightmost derivation in reverse; bottom-up via Shift-Reduce actions on a stack; more expressive, handles left-recursive grammars naturally.
What is a Shift-Reduce Conflict versus a Reduce-Reduce Conflict?
• Reduce-Reduce: The parser reaches a state matching two distinct production rules simultaneously, indicating a severe grammar ambiguity.
Why do modern runtimes (JVM, V8, Python) translate ASTs to Bytecode instead of tree-walking?