Parsing questions

Q9

GATE CS 2013 CSParsingMCQ1 mark−1/3 if wrong
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type A→ϵA \to \epsilon and A→aA \to a) to parse a string with nn tokens?
Show answer without attempting

Answer: B

Q40

GATE CS 2013 CSParsingMCQ2 marks−2/3 if wrong
Consider the following two sets of LR(1) items of an LR(1) grammar.

<br>X→c⋅X,c/dX→c⋅X,$<br>X→⋅cX,c/dX→⋅cX,$<br>X→⋅d,c/dX→⋅d,$<br>\begin{array}{ll}<br>X \to c\cdot X, c/d & X \to c\cdot X, \$ \\<br>X \to \cdot cX, c/d & X \to \cdot cX, \$ \\<br>X \to \cdot d, c/d & X \to \cdot d, \$<br>\end{array}

Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?

1. Cannot be merged since look aheads are different.
2. Can be merged but will result in S-R conflict.
3. Can be merged but will result in R-R conflict.
4. Cannot be merged since goto on cc will lead to two different sets.
Show answer without attempting

Answer: D

0/20 correct0 marks

Related topics in Compiler Design