MCQ Bank
In shift-reduce parsing, what does a handle represent?
- A) The terminal symbol at the top of the parser's stack.
- B) The right-hand side of a production rule that matches a portion of the input string.
- C) The non-terminal symbol on the left-hand side of a production rule.
- D) The current state of the parser's stack.
By setting the initial state and marking the remaining entries as "error", the LR table is properly initialized to begin the LR parsing process.
- A) False
- B) True
- C)
- D)
In an LR(1) parser, which of the following actions consumes the input (i.e., advance the input by consuming the current token)?
- A) Reduce
- B) Accept
- C) Error
- D) Shift
The canonical collection is constructed by repeatedly applying which operations?
- A) Closure and shift
- B) Shift and reduce
- C) Reduce and goto
- D) Closure and goto
What is the upper frontier in a partially constructed parse tree?
- A) The leftmost part of the tree.
- B) The bottommost part of the tree.
- C) The topmost part of the tree.
- D) The rightmost part of the tree.
For each ____________, add production rule "A → α" to LL(1) parsing table entry M[A, a].
- A) Non-terminal 'A' in FOLLOW(α).
- B) Terminal 'a' in FIRST(α).
- C) Terminal 'a' in FOLLOW(α).
- D) Non-terminal 'A' in FIRST(α).
The NFA of LR(0) items represents transitions between:
- A) LR(1) items.
- B) Non-terminal symbols and their productions.
- C) LR(0) items without considering lookahead symbols.
- D) Grammar symbols and their derivations.
If the parsing loop terminates without encountering any errors, then the parsing process is considered as successful.
- A) False
- B) True
- C)
- D)
The augmented grammar has its own start symbol, while original grammar includes an additional production rule, called the augmented start production.
- A) False
- B) True
- C)
- D)
What does the GoTo table in the DFA representation table represent?
- A) Accepting the input
- B) Transitioning to terminals
- C) Applying production rules
- D) Transitioning to non-terminals
A top-bottom parser operates by repeatedly locating handles on the frontier of the partial parse tree and performing reductions that they specify.
- A) True
- B) False
- C)
- D)
When transitioning from "A → α•Xη" to "A → αX•η" in the NFA of LR(0) items, the symbol X is a/an ____________ symbol.
- A) Non-terminal
- B) Terminal
- C) Lookahead
- D) Start
Is it true that LR parsers do not need left-factored grammars?
- A) Yes
- B) No
- C)
- D)
If the parser encounters an unexpected input symbol or an invalid configuration, then an accept action is taken.
- 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) True
- B) False
- C)
- D)
In the context of canonical collection of LR(1) items, if a non-terminal appears after the placeholder "·" then no further closure is possible.
- A) True
- B) False
- C)
- D)
The canonical collection is used to generate which of the following parsing tables?
- A) Action and goto tables
- B) Production and symbol tables
- C) First and follow tables
- D) Closure and reduction tables
LR parsers are commonly used for:
- A) Syntax analysis
- B) Lexical analysis
- C) Code generation
- D) Register Allocation
Which direction does a bottom-up parser use to build the parse tree?
- A) From the root to the leaves.
- B) From the right to the left.
- C) From the left to the right.
- D) From the leaves to the root.
The augmented grammar is particularly important in which parsing algorithm?
- A) Top-down parsing.
- B) Recursive descent parsing.
- C) LL(1) parsing.
- D) LR(1) parsing.