Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q951: Which token is used in the YACC calculator grammar to represent a number?
- A: NUMBER
- B: LPAREN
- C: RPAREN
- D: EQUAL
View Answer
A
Q952: The YACC operator to specify precedence and associativity for tokens is ________.
- A: %left
- B: %token
- C: %type
- D: %union
View Answer
A
Q953: The code snippet {$ $= $1 + $3;} in YACC indicates addition of which elements?
- A: First and third expr symbols
- B: First and second tokens
- C: Second and third tokens
- D: First and second expr
View Answer
A
Q954: In the production expr : expr MINUS expr {$ $= $1 - $3;}, $1 and $3 refer to ________.
- A: The first and third expr values
- B: The first and second tokens
- C: The second and third tokens
- D: The second and third expr
View Answer
A
Q955: In YACC, the notation $$ refers to the ________.
- A: Left hand side symbol value
- B: Right hand side first token
- C: Right hand side second token
- D: Right hand side third token
View Answer
A
Q956: In YACC, the type of value stored in the parse stack can be declared using ________.
- A: %union
- B: %token
- C: %left
- D: %nonassoc
View Answer
A
Q957: The dummy token used to handle unary minus precedence in the example is ________.
- A: UMINUS
- B: MINUS
- C: PLUS
- D: TIMES
View Answer
A
Q958: In the grammar rule expr : LPAREN expr RPAREN {$ $= $2;}, $2 refers to the value of ________.
- A: expr inside parentheses
- B: LPAREN token
- C: RPAREN token
- D: The entire expression
View Answer
A
Q959: The intermediate representation (IR) in compilers is mainly used to ________.
- A: Pass information between passes
- B: Generate executable code
- C: Perform lexical analysis
- D: Detect syntax errors
View Answer
A
Q960: The symbol table is considered part of the ________ in compiler design.
- A: Intermediate Representation
- B: Lexical Analyzer
- C: Parser
- D: Code Generator
View Answer
A