Difficulty: Easy
Correct Answer: Recognize major language constructs and invoke actions to build an intermediate representation
Explanation:
Introduction / Context:
After lexical analysis produces tokens, the syntax analysis (parser) checks whether token sequences follow the grammar and typically builds an intermediate representation (IR) such as parse trees, abstract syntax trees, or quadruples/matrices.
Given Data / Assumptions:
Concept / Approach:
Parsing uses context-free grammars and parsing algorithms (LL, LR, etc.) to recognize productions. On recognizing a construct, the parser calls semantic actions to construct an IR node or emit intermediate code.
Step-by-Step Solution:
Start from tokens supplied by the scanner.Apply grammar to validate structure and detect syntax errors.On successful matches, build IR (trees, DAGs, three-address code).
Verification / Alternative check:
Compiler texts consistently separate tokenization (lexical) from grammar recognition (syntax) and postpone machine code emission to later phases.
Why Other Options Are Wrong:
(b), (c) belong primarily to lexical/early symbol management. (d) “Parse into basic tokens” is lexical work, not syntax. (e) Final machine code is a back-end responsibility.
Common Pitfalls:
Mixing scanning and parsing tasks; assuming direct code generation during parsing.
Final Answer:
Recognize major language constructs and invoke actions to build an intermediate representation.
Discussion & Comments