GATE CS 2021 Set 2 | Question 13
Compiler Design › Parser · MCQ · 1 mark · Answer: C
- Question 13Compiler Designmcq1 markConsider the following ANSI C program.
Which one of the following phases of a compiler will detect the error (if any) in the above program?int main() { Integer x; return 0; }- A.Lexical analyzer
- B.Syntax analyzer
- C.Semantic analyzer✓
- D.Machine dependent code optimizer
Answer: C
Solution
Integeris a valid identifier token (passes lexical analysis) andInteger x;is syntactically a valid declaration form (passes parsing). The error — thatIntegeris not a declared type — is caught during semantic analysis. - A.
More GATE PYQ on Parser
All GATE CS Compiler Design PYQ →Attempt GATE CS 2021 Set 2 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →