MCQ Bank
What would be the potential handle for the grammar "T → Ua, U → vw" at the start of Shift-Reduce parsing?
- A) <T → Ua, 1>
- B) <U → vw,1>
- C) <U → wv,1>
- D) <T → aU, 1>
What is the upper frontier in a partially constructed parse tree?
- A) The bottommost part of the tree.
- B) The topmost part of the tree.
- C) The leftmost part of the tree.
- D) The rightmost part of the tree.
The Closure procedure inserts a dot ('•') before the production γ to:
- A) Identify the non-terminal symbols in the production.
- B) Indicate the start of a reduction.
- C) Track the position of the dot in the grammar rules.
- D) Mark the completion of the left context.
Shift-Reduce parser uses a/an ____________ to hold grammar symbols.
- A) Tree
- B) Stack
- C) Array
- D) Queue
In the context of canonical collection of LR(1) items, compute the state I0 for the grammar " S → E, E → E + (E) | int".
- A) s = { [S → •E, $] , [S → •S + (S),$] , [E → •int, $] }
- B) s = { [S → •E, $] , [E → •E + (E),$] , [E → •int, $] }
- C) s = { [E → •S, $] , [E → •E + (E),$] , [E → •int, $] }
- D) s = { [E → •S, $] , [S → •S + (S),$] , [E → •int, $] }
Left factoring is primarily used in which type of parsing?
- A) Shift-Reduce parsing
- B) Bottom-up parsing
- C) LR parsing
- D) Predictive parsing
For the grammar "S → a c T | a U", it is very easy to predict because two productions start with 'a'.
- A) True
- B) False
- C)
- D)
In a shift-reduce parser, a placeholder is used to represent an incomplete or partial structure during the parsing process.
- A) False
- B) True
- C)
- D)
After performing left factoring on the grammar "S → a X | a", the resultant grammar will be;
- A) S → a X, S'→ S | ε
- B) S → X a, S'→ S | ε
- C) S → S' a, S'→ X | ε
- D) S → a S', S'→ X | ε
Which of the following production contains a placeholder at its end of right-hand side?
- A) Expr → Expr • – Term
- B) Expr → Expr – Term •
- C) Expr → Expr – •Term
- D) Expr → • Expr –Term
In the handle representation <A → α, k>, what does k represent?
- A) The index of the first symbol in the handle.
- B) The length of the handle.
- C) The number of non-terminal symbols in the handle.
- D) The position of the handle within the input string.
The NFA of LR(0) items represents transitions between:
- A) LR(0) items without considering lookahead symbols.
- B) Non-terminal symbols and their productions.
- C) LR(1) items.
- D) Grammar symbols and their derivations.
The canonical collection is used to generate which of the following parsing tables?
- A) Action and goto tables
- B) First and follow tables
- C) Closure and reduction tables
- D) Production and symbol tables
The input to the algorithm for the construction of collection of canonical sets of LR(1) items is _______________.
- A) Original Grammar G
- B) Augmented Grammar G'
- C) CC sets of LR(1)
- D) CC sets of LR(0)
In bottom-up parsing, _______________ conflicts occur when the parser encounters a state where it needs to decide between shifting and reducing.
- A) Terminal-Nonterminal
- B) Precedence-Associativity
- C) Continue-Goto
- D) Shift-Reduce
The output from the algorithm for the construction of collection of canonical sets of LR(1) items is _______________.
- A) CC sets of LR(0)
- B) Original Grammar G
- C) Augmented Grammar G'
- D) CC sets of LR(1)
In LR table construction, for each non-terminal A Î G; if goto (Ii, A) = Ij , then _______________.
- A) Goto [i, A] ← j
- B) Goto [i, G] ← j
- C) Goto [i, A] ← i
- D) Goto [i, G] ← i
In Shift-Reduce parser, the handle-recognizing DFA is basically represented as a 2-dimensional table, where ____________ correspond to terminals and non-terminals.
- A) Rows
- B) Captions
- C) Columns
- D) Cells
If [X → α • β, c] is an LR(1) item, then "c" is a/an _______________.
- A) Non-terminal
- B) Terminal
- C) Production
- D) Look-ahead symbol
The pair <A → β, k> is called the handle of the ____________ parse.
- A) Bottom-Up
- B) Bottom-Down
- C) Top-Up
- D) Top-Down