LL(1) chooses each production using what amount of lookahead?
A Two parse stacks
B Machine opcode
C One lookahead token
D Whole program scan
Answer: C. One lookahead token. An LL(1) parser uses one lookahead token to select a production.
The top-down method begins at the start symbol and expands productions; what is it called?
A Top-down parsing
B Bottom-up parsing
C Code scheduling
D Register allocation
Answer: A. Top-down parsing. Top-down parsing begins with the start symbol and expands productions toward input tokens.
During shift-reduce parsing, consuming the next token is which action?
A Emit machine code
B Allocate a register
C Consume next token
D Replace grammar rule
Answer: C. Consume next token. A shift moves the next input token onto the parser stack.
Replacing a handle by its left side is called which parser action?
A Shift
B Reduce
C Scan
D Backpatch
Answer: B. Reduce. A reduction replaces a recognized production body, the handle, with its left-hand nonterminal.
Simple predictive parsing requires rewriting grammars with what property?
A Terminals
B Operator precedence
C Right recursion
D Left recursion
Answer: D. Left recursion. Left-recursive rules can make a recursive-descent parser call itself without consuming input.
Shared prefixes can be extracted by which technique to delay a choice?
A Code motion
B Constant folding
C Left factoring
D Spilling
Answer: C. Left factoring. Left factoring extracts a common prefix so a parser can decide after seeing more input.
Each nonterminal can map to a procedure in which parser style?
A LR parser
B Lexical scanner
C GLR parser
D Recursive descent
Answer: D. Recursive descent. A recursive-descent parser commonly implements grammar nonterminals as mutually recursive procedures.
FIRST(X) contains what can begin strings derived from X?
A Target labels
B AST children
C FOLLOW(X) tokens
D FIRST(X) terminals
Answer: D. FIRST(X) terminals. FIRST(X) contains terminals that can begin strings derived from X.
Tokens that may follow X belong to which set?
A Use set
B FOLLOW(X)
C FIRST(X)
D Token class
Answer: B. FOLLOW(X). FOLLOW(X) describes terminals that may appear immediately after X in a derivation.
For S β aA | b, what is FIRST(S)?
A {a, b}
B {b}
C {Ξ΅}
D {a}
Answer: A. {a, b}. Each alternative begins with a distinct terminal, so FIRST(S) contains a and b.
In a grammar, Ξ΅ denotes which string?
A End marker
B Start symbol
C Empty string
D Wildcard token
Answer: C. Empty string. Epsilon denotes the empty string, which contains no symbols.
Two rules enter one LL(1) table cell; what does this create?
A Code generation
B Type inference
C Successful reduction
D Parsing conflict
Answer: D. Parsing conflict. A table cell with competing productions prevents a unique LL(1) choice.
Using one next token to predict a rule describes which parser?
A Assembler
B Predictive parser
C Shift-only parser
D Interpreter
Answer: B. Predictive parser. A predictive parser uses lookahead to select a grammar production.
End-of-file is marked by which special token?
A End-of-file
B Epsilon
C Lookahead set
D Start symbol
Answer: A. End-of-file. The end-of-file marker indicates that no more input tokens remain.
After a syntax error, synchronization recovery seeks what?
A Known boundary token
B New register
C Operator precedence
D Source comment
Answer: A. Known boundary token. A recovery parser skips input until a selected synchronizing token or boundary is found.
Child-node values produce which kind of attributes?
A Child nodes
B Input files
C Machine registers
D Parent scope
Answer: A. Child nodes. A synthesized attribute is computed from attributes of a node’s children.
Context often travels from parents or siblings through what attributes?
A Lexer states
B Parents or siblings
C Code buffer
D Target labels
Answer: B. Parents or siblings. Inherited attributes carry context from a parent or related sibling in the syntax tree.
With no coercion, integer plus string is rejected during which phase?
A Lexical analysis
B Linking
C Instruction scheduling
D Semantic analysis
Answer: D. Semantic analysis. Type compatibility is a semantic property checked after tokens and syntax are recognized.
Visibility region of a declaration is called what?
A Basic block
B Handle
C Token
D Scope
Answer: D. Scope. A declaration’s scope is the region in which its name may be referenced.
Shadowed names are looked up first in which scope?
A Global scope
B Target section
C Innermost scope
D Parser state
Answer: C. Innermost scope. Lexical-scope lookup checks the nearest enclosing scope first.
Three-address code can split t=a*b+c into which sequence?
A t1=a*c; t=t1+b
B t1=a*b; t=t1+c
C t1=a+b; t=t1*c
D t=a*(b+c)
Answer: B. t1=a*b; t=t1+c. Three-address statements split the multiplication and addition into separate operations.
The postfix encoding for a+b*c is what?
A a b c * +
B a b c + *
C a b + c *
D + a * b c
Answer: A. a b c * +. Postfix places each operator after its operands, with multiplication before addition.
Safe reuse of a prior expression needs what conditions?
A Types are different
B Operands renamed; memory changed
C Operands unchanged; no side effects
D Control flow unknown
Answer: C. Operands unchanged; no side effects. Reuse is safe only when the expression’s value has not been invalidated.
Inside Bison error rules, what reserved token may appear?
A EOF
B error
C shift
D epsilon
Answer: B. error. Bison reserves the error token for grammar-based syntax-error recovery.
Compared with a concrete syntax tree, what detail may an AST omit?
A AST removes operators
B AST contains only tokens
C AST stores machine code
D AST omits grammar detail
Answer: D. AST omits grammar detail. An abstract syntax tree omits redundant grammar structure while retaining meaningful operations.