MCQ Bank
In Shift-Reduce parsing, every legal input eventually reduces the entire frontier to grammar’s goal symbol.
- A) False
- B) True
- C)
- D)
Is it true that LR parsers do not need left-factored grammars?
- A) Yes
- B) No
- C)
- D)
What should be added to the LL(1) parsing table entry M[A, a] during the construction process?
- A) The non-terminal A.
- B) The production rule A → α.
- C) The FOLLOW set of A.
- D) The FIRST set of A.
The upper frontier in a shift-reduce parser is the set of symbols at the top of the parser's stack that have not been reduced yet.
- A) True
- B) False
- C)
- D)
If [X → α • β, a] is an LR(1) item, then symbol "•" (between α and β) represents a/an _______________.
- A) Placeholder
- B) Terminal
- C) Production
- D) Non-terminal
The augmented grammar is particularly important in which parsing algorithm?
- A) Recursive descent parsing.
- B) LR(1) parsing.
- C) LL(1) parsing.
- D) Top-down parsing.
If closure(I) is "I0 = [S' → ·S, S → ·s]" for a typical grammar, then goto(I0, s) would be _______________.
- A) S → S·
- B) S → s·
- C) S' → s·
- D) S' → S·
One of the rationales behind the Closure procedure is to:
- A) Handle conflicts arising from ambiguous grammar rules.
- B) Determine potential reductions and expansions in the grammar.
- C) Optimize the performance of the parsing algorithm.
- D) Identify grammar errors in the production rules.
The recognition of potential handles is crucial for the parser to:
- A) Decide when to perform a reduce operation.
- B) Determine the previous state in the parsing table.
- C) Decide when to perform a shift operation.
- D) Determine the next state in the parsing table.
If the parser encounters an unexpected input symbol or an invalid configuration, then an accept action is taken.
- A) False
- B) True
- C)
- D)
Is it true that assigning precedence levels to grammar rules or tokens can help resolve shift-reduce conflicts?
- A) Yes
- B) No
- C)
- D)
LR parsers CAN NOT handle left-recursive grammars.
- A) False
- B) True
- C)
- D)
Which direction does a bottom-up parser use to build the parse tree?
- A) From the leaves to the root.
- B) From the left to the right.
- C) From the right to the left.
- D) From the root to the leaves.
In an LR(1) parser, which of the following actions consumes the input (i.e., advance the input by consuming the current token)?
- A) Error
- B) Reduce
- C) Accept
- D) Shift
In shift-reduce parsing, Shift action moves ► one place to the ________________ which shifts a terminal to the left string.
- A) Right
- B) Top
- C) Bottom
- D) Left
Which of the following production contains a placeholder at its start of right-hand side?
- A) Expr → Expr – Term •
- B) Expr → • Expr –Term
- C) Expr → Expr • – Term
- D) Expr → Expr – •Term
Compare the size of parsing tables generated by an original grammar and an augmented grammar;
- A) The size of the parsing table is smaller for the original grammar.
- B) The size of the parsing table is the same for both grammars.
- C) The size of the parsing table is larger for the original grammar.
- D) The size of the parsing table is larger for the augmented grammar.
Which of the following is NOT a step in the closure procedure for an LR item?
- A) Identify the symbols immediately following the dot in the item.
- B) Compute the FIRST set for the nonterminal symbol following the dot.
- C) Determine the lookahead symbols for the item.
- D) Add the item to the closure set.
In the reduce action, the shift-reduce parser applies an inverse production at the right end of the ________________ string.
- A) Left
- B) Right
- C) Bottom
- D) Top
In the context of Shift-Reduce parser, the number of complete handles is equal to the number of ____________.
- A) Terminals
- B) Symbols
- C) Non-terminals
- D) Productions