Practice free →
HomeGATE CSEcomputerscienceCompiler Design › After the parser produces an AST, the next compi…

After the parser produces an AST, the next compiler phase is typically

Ascanning
Bsemantic analysis
Clinking
Dgarbage collection
Answer & Solution
Correct answer: B. semantic analysis
1. Typical compiler pipeline: - Scanner → tokens - Parser → AST - Semantic analyser → annotated AST (types, scopes, etc.) - Optimiser → intermediate representation - Code generator → machine code 2. Semantic analysis catches errors the parser cannot: - Type mismatches (e.g. adding string to integer) - Undefined variables / functions - Scope rules (variable used out of scope) 3. Scanning (A) is the FIRST phase, not after parsing. Linking (C) and GC (D) are unrelated to AST processing. _Source: Bob Nystrom, "Crafting Interpreters", Ch 1 (compiler pipeline overview)._
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions