Babel parses modern JavaScript into an AST using Babylon lexer/parser, applies AST transformations, and generates backwards-compatible ES5 code.
Visual representation of control loops, memory layout, and execution flow for Phases of a Compiler & AST Construction.
Scans raw character stream and emits a stream of Tokens (Keywords, Identifiers, Operators).
Validates tokens against Context-Free Grammar (CFG) to construct Abstract Syntax Tree (AST).
Checks type consistency, function signature matches, and variable scope declarations.
Transforms IR to eliminate dead code and emits optimized target assembly machine instructions.
| Feature / Dimension | Compiler | Interpreter |
|---|---|---|
| Execution Method | Translates entire program into machine code BEFORE execution | Translates and executes source code line-by-line on the fly |
| Speed | Faster execution time (pre-compiled binary code) | Slower execution time (overhead of parsing during execution) |
Detailed answers, interviewer pro tips, key takeaway summaries, and code examples formulated for technical rounds.
✅ Correction: Parenthesis matching and grammar validation is performed by the Syntax Analyzer (Parser), not the Lexer.
Sequence of translation passes converting high-level code to assembly.