Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q901: The token definitions in YACC are written using which directive?
  • A: %token
  • B: %define
  • C: %grammar
  • D: %lex
View Answer
A

Q902: Flex is primarily used for:
  • A: Lexical analysis
  • B: Syntax analysis
  • C: Semantic analysis
  • D: Code generation
View Answer
A

Q903: The regular expression "+" in Flex returns which token?
  • A: PLUS
  • B: MINUS
  • C: TIMES
  • D: DIVIDE
View Answer
A

Q904: In the calculator example, LPAREN and RPAREN tokens represent:
  • A: Left and right parentheses
  • B: Addition and subtraction
  • C: Multiplication and division
  • D: Numbers
View Answer
A

Q905: Beyond syntax analysis, questions depend on ________, not just parts of speech.
  • A: Values
  • B: Tokens
  • C: Keywords
  • D: Symbols
View Answer
A

Q906: Context-sensitive analysis answers may involve ________.
  • A: Computation
  • B: Syntax parsing
  • C: Lexical analysis
  • D: Semantic error detection
View Answer
A

Q907: Which formal method is popular for context-sensitive analysis?
  • A: Attribute grammars
  • B: Context-free grammars
  • C: Regular expressions
  • D: Finite automata
View Answer
A

Q908: Attribute grammars augment a CFG with ________.
  • A: Rules to compute values
  • B: Additional terminals
  • C: Extra non-terminals
  • D: Parsing tables
View Answer
A

Q909: In the grammar for signed binary numbers (SBN), the start symbol is ________.
  • A: Number
  • B: Sign
  • C: List
  • D: Bit
View Answer
A

Q910: In the SBN grammar, Sign can be ________ or ________.
  • A: +, –
  • B: 0, 1
  • C: A, B
  • D: True, False
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now