Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q511: The expression `tree = op3->AST();` in `Tprime::isPresent()` shows ________.
- A: Tree merging
- B: Loop breaking
- C: Syntax checking
- D: Parsing ID
View Answer
C
Q512: Which function checks for the presence of multiplication or division operators?
- A: Expr::isPresent()
- B: Tprime::isPresent()
- C: Eprime::isPresent()
- D: Factor::isPresent()
View Answer
B
Q513: TreeNode objects are created during parsing to build __________.
- A: A GUI
- B: Tree Structure
- C: Compiler interface
- D: Parse Table
View Answer
B
Q514: In recursive descent parsing, the parser directly uses __________.
- A: AST traversal
- B: Stack memory
- C: Control flow and function calls
- D: Finite automata
View Answer
C
Q515: The `s->advance()` call inside parentheses parsing occurs ________ the closing RPAREN check.
- A: before
- B: after
- C: only if needed
- D: never
View Answer
B
Q516: Each `isPresent()` function generally returns true only if ________.
- A: At least one sub-part is missing
- B: The parse tree is complete
- C: The syntax is invalid
- D: The program ends
View Answer
B
Q517: The role of `new Term(s)` in `Expr::isPresent()` is to ________.
- A: Handle subtraction
- B: Create a Term parser object
- C: Delete a class
- D: Trigger an error
View Answer
B
Q518: Tree construction in these classes is done by ________.
- A: Appending tokens
- B: Linking operators with operands
- C: Sorting tokens in order
- D: Matching all token types
View Answer
B
Q519: The `Factor::isPresent()` method parses expressions inside __________.
- A: square brackets
- B: parentheses
- C: double quotes
- D: angle brackets
View Answer
B
Q520: If the next token is neither ID, NUM, nor LPAREN, `Factor::isPresent()` will ________.
- A: return true
- B: call AST()
- C: throw syntaxError(s)
- D: return false
View Answer
D