Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q941: For List → Bit, List.val is assigned as ________.
- A: Bit.val
- B: List.val
- C: Bit.pos
- D: List.pos
View Answer
A
Q942: For List0 → List1 Bit, List0.val is computed as ________.
- A: 2 × List1.val + Bit.val
- B: List1.val + Bit.val
- C: List1.val – Bit.val
- D: Bit.val – List1.val
View Answer
A
Q943: The LR(1) parser's "shift" action pushes token and ________ onto the stack.
- A: State index i
- B: Grammar symbol A
- C: Next token
- D: Parsing rule
View Answer
A
Q944: In the LR(1) parser, Goto[s,A] gives the ________.
- A: Next state after reduction
- B: Previous state
- C: Current token
- D: Current state
View Answer
A
Q945: In the ad-hoc scheme, the parser passes values of attributes from one snippet to ________.
- A: Another snippet
- B: The scanner
- C: The lexer
- D: The optimizer
View Answer
A
Q946: YACC notation for snippets is adopted to ________.
- A: Pass attribute values
- B: Optimize code
- C: Generate machine code
- D: Handle syntax errors
View Answer
A
Q947: In the LR(1) parser skeleton, the stack stores pairs of 〈symbol, state〉 which can be replaced with ________.
- A: Triples 〈value, symbol, state〉
- B: Triples 〈token, state, symbol〉
- C: Triplets 〈state, symbol, value〉
- D: Pairs 〈value, state〉
View Answer
A
Q948: When pushing onto the stack after reduction in the ad-hoc scheme, the parser pushes ________ along with symbol.
- A: Value
- B: Token
- C: State
- D: Next token
View Answer
A
Q949: The notation 〈value, symbol, state〉 on the parser stack is used to implement ________.
- A: Attribute value passing
- B: Lexical analysis
- C: Code generation
- D: Syntax error detection
View Answer
A
Q950: In YACC, the token declarations start with the keyword ________.
- A: %token
- B: %union
- C: %type
- D: %left
View Answer
A