Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 31
Q921:
Attribute grammars help to compute ________ in compiler design.
A. Semantic values
B. Lexical tokens
C. Parsing tables
D. Syntax errors
Correct Answer:
A
Chapter: 31
Q922:
The attribute List.val for List → Bit is computed as ________.
A. Bit.val
B. List.pos
C. Bit.pos
D. Number.val
Correct Answer:
A
Chapter: 31
Q923:
The attribute Sign.neg is assigned false when Sign → ________.
A. +
B. –
D. 1
Correct Answer:
A
Chapter: 31
Q924:
The attribute Number.val when Sign.neg is false is assigned as ________.
A. List.val
B. –List.val
C. Sign.neg
Correct Answer:
A
Chapter: 31
Q925:
The attribute dependence graph is derived from ________.
A. Rules and parse tree
B. Token stream
C. Lexical analyzer
D. Symbol table
Correct Answer:
A
Chapter: 31
Q926:
The attribute Bit.pos in the parse tree is always assigned relative to ________.
A. List.pos
B. Sign.neg
C. Number.val
D. Bit.val
Correct Answer:
A
Chapter: 32
Q927:
In the dynamic method of attribute evaluation, the compiler builds the parse tree and then builds ________.
A. The dependence graph
B. The syntax tree
C. The symbol table
D. The lexical analyzer
Correct Answer:
A
Chapter: 32
Q928:
In dynamic method, attributes are evaluated in ________ order.
A. Topological
B. Reverse topological
C. Random
D. Lexical
Correct Answer:
A
Chapter: 32
Q929:
Rule-based (or treewalk) methodology determines a ________ ordering at compiler generation time.
A. Fixed (static)
B. Dynamic
C. Random
D. Topological
Correct Answer:
A
Chapter: 32
Q930:
Oblivious (passes, dataflow) methodology ________ the attribute rules and parse tree.
A. Ignores
B. Analyzes
C. Builds dependency graph
D. Sorts topologically
Correct Answer:
A
Chapter: 32
Q931:
A main problem with attribute grammars is ________.
A. Storage management for short-lived attributes
B. Excessive parsing time
C. Too many syntax errors
D. Lack of formal grammar
Correct Answer:
A
Chapter: 32
Q932:
The variation of attribute grammars used in many compilers is called ________.
A. Ad-hoc analysis
B. Static analysis
C. Dynamic evaluation
D. Context-free analysis
Correct Answer:
A
Chapter: 32
Q933:
In rule-based evaluators, actions are associated with ________.
A. Grammar productions
B. Tokens
C. Parsing tables
D. Symbol tables
Correct Answer:
A
Chapter: 32
Q934:
Code snippets associated with grammar productions execute at ________ time.
A. Parse
B. Compile
C. Link
D. Run
Correct Answer:
A
Chapter: 32
Q935:
In bottom-up shift-reduce parsers, actions are performed during ________.
A. Each reduction
B. Each shift
C. Each scan
D. Each parse
Correct Answer:
A
Chapter: 32
Q936:
In LR(1) parser, after popping stack during reduction, the parser pushes ________.
A. A and Goto[s,A]
B. β and token
C. Only token
D. Only A
Correct Answer:
A
Chapter: 32
Q937:
When Action[s,token] is "shift i", the parser ________.
A. Pushes token and i onto stack
B. Pops stack
C. Reduces
D. Calls scanner again
Correct Answer:
A
Chapter: 32
Q938:
The code snippet for the production Number → Sign List assigns Number.val as ________.
A. – Sign.val × List.val
B. Sign.val + List.val
C. Sign.val – List.val
D. Sign.val × List.val
Correct Answer:
A
Chapter: 32
Q939:
For Sign → +, Sign.val is assigned ________.
A. 1
B. –1
D. 2
Correct Answer:
A
Chapter: 32
Q940:
For Sign → –, Sign.val is assigned ________.
A. –1
B. 1
D. 2
Correct Answer:
A