MCQ Bank
The purpose of the added ε-transitions in the NFA is to:
- A) Resolve conflicts in the parsing process.
- B) Recognize the symbols β before a reduction by X → β.
- C) Identify the start state of the grammar.
- D) Push the non-terminal X onto the parse stack.
In LR grammar, the L stands for ________________.
- A) Left to right scan
- B) Left hand side of grammar
- C) Left most derivation
- D) Left Shift
This initial state signifies the starting point of the parsing process and serves as the entry point for constructing the LR table.
- A) True
- B) False
- C)
- D)
In the grammar "A → a d c b | a d b c", the ____________ is a common prefix for non-terminal 'A'.
- A) b
- B) d c b
- C) a d
- D) a b c d
If X is a non-terminal symbol, the transition on symbol X in the NFA of LR(0) items corresponds to:
- A) Shifting X from the parse stack to the input.
- B) Applying the closure operation to the LR(0) items.
- C) Determining the valid lookahead symbols.
- D) Performing a reduction based on the production rule X → γ.
What is the purpose of the augmented start production in the augmented grammar?
- A) It ensures that the grammar meets the requirements of parsing algorithms.
- B) It indicates the end of the input for parsing purposes.
- C) It represents the first production rule in the grammar.
- D) It introduces a new non-terminal symbol in the grammar.
A top-bottom parser operates by repeatedly locating handles on the frontier of the partial parse tree and performing reductions that they specify.
- A) False
- B) True
- C)
- D)
For every LR(0) item "A → α•Xη", the ε-transitions are added for:
- A) The terminal symbols in the input sequence.
- B) The lookahead symbols of X.
- C) The non-terminal symbols in the grammar.
- D) The production rules containing X as a non-terminal.
In the context of LR(1) parser, the construction of _______________ begins by building a model of parser’s initial state.
- A) Handle
- B) Canonical Collection
- C) Upper Frontier
- D) Closure Procedure
In the handle representation <A → α, k>, where A is the left-hand side non-terminal and α is the right-hand side, what does α represent?
- A) The entire input string.
- B) The stack symbols of the parser.
- C) The input symbols matched by the handle.
- D) The handle itself.
The action table in the DFA representation table is used for:
- A) Shifting terminals
- B) Transitioning to non-terminals
- C) Accepting the input
- D) Reducing using production rules
In the LR item [S' → •S, $], the "S" represents a non-terminal symbol in the grammar.
- A) True
- B) False
- C)
- D)
The augmented grammar has its own start symbol, while original grammar includes an additional production rule, called the augmented start production.
- A) True
- B) False
- C)
- D)
Which of the following is NOT a step in the closure procedure for an LR item?
- A) Add the item to the closure set.
- B) Determine the lookahead symbols for the item.
- C) Identify the symbols immediately following the dot in the item.
- D) Compute the FIRST set for the nonterminal symbol following the dot.
For the grammar "S → a c T | a U", it is very easy to predict because two productions start with 'a'.
- A) False
- B) True
- C)
- D)
If find ε in FIRST(α), add production rule "A → α" to LL(1) parsing table entry M[A, b] for each ____________ in FOLLOW(A).
- A) Non-Terminal B
- B) Terminal a
- C) Terminal b
- D) Non-Terminal A
In an LR(1) parser, Reduce action does not consume the input, while shift action advances the input by consuming the current token.
- A) True
- B) False
- C)
- D)
At the start of LR(1) parser, a dummy symbol is pushed on stack "stack.push(dummy)". The purpose of it is;
- A) To prevent stack underflow during reduction operations.
- B) To handle conflicts in the parsing tables.
- C) To assist in error recovery when encountering unexpected tokens.
- D) To indicate the end of the parsing process.
In the reduce action, the shift-reduce parser applies an inverse production at the right end of the ________________ string.
- A) Left
- B) Right
- C) Top
- D) Bottom
In the context of LR(1) parser, each set in _______________ represents a state in the eventual parser DFA.
- A) Upper Frontier
- B) Handle
- C) Canonical Collection
- D) Closure Procedure