MCQ Bank
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
In shift-reduce parsing, what does a handle represent?
- A) The non-terminal symbol on the left-hand side of a production rule.
- B) The right-hand side of a production rule that matches a portion of the input string.
- C) The terminal symbol at the top of the parser's stack.
- D) The current state of the parser's stack.
LR parsers are commonly used for:
- A) Lexical analysis
- B) Register Allocation
- C) Code generation
- D) Syntax analysis
In bottom-up parsing, _______________ conflict occurs when the parser encounters a state where it has multiple valid shift actions but needs to decide which one to choose.
- A) Reduce-Reduce
- B) Shift-Reduce
- C) Shift-Shift
- D) Reduce-Shift
In the LR table, how are the entries other than the state containing [S' → •S, $] initialized?
- A) Assigned with shift actions
- B) Marked as "accept"
- C) Marked as "error"
- D) Assigned with reduce actions
In LR(1) parser, the Action table specifies the next state, while the GoTo table determines the particular action (i.e., shift / reduce).
- A) False
- B) True
- C)
- D)
In the context of LR(1) parser, each set in _______________ represents a state in the eventual parser DFA.
- A) Upper Frontier
- B) Closure Procedure
- C) Canonical Collection
- D) Handle
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 the context of Shift-Reduce parser, the number of potential handles for a grammar is equal to the ____________ of the lengths of the right-hand side of all the productions.
- A) Multiplication
- B) Division
- C) Sum
- D) Subtraction
In LR grammar, the R stands for ________________.
- A) Right shift
- B) Right most derivation
- C) Right hand side of grammar
- D) Right to left scan
In the LR(1) parser code, the statement "stack.pop(2×|β|)" pops twice the length of the _______________ side of the production rule from the stack.
- A) Bottom-hand
- B) Right-hand
- C) Top-hand
- D) Left-hand
In the context of canonical collection of LR(1) items, if a terminal appears after the placeholder "·" then no further closure is possible.
- A) False
- B) True
- C)
- D)
In compiler construction, an LR parser is a type of:
- A) Bottom-up parser
- B) Non-recursive parser
- C) Top-down parser
- D) Recursive descent parser
In the context of LR(1) parser, which of the following forms the GoTo table in the DFA representation table?
- A) Columns with non-terminals
- B) Rows with non-terminals
- C) Rows with terminals
- D) Columns with terminals
What does the term "canonical collection" refer to in LR parsing?
- A) A list of production rules in a grammar.
- B) The final output of the parsing process.
- C) A set of LR items representing the states of the parser during parsing.
- D) A table used for storing parsing actions.
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)
In the grammar "T → a b c d | a b d c", the ____________ is a common prefix for non-terminal 'T'.
- A) c d
- B) a b
- C) a c
- D) b d