CD |Gate-2013| Previous Year Questions| Set-8

Set-15 GATE-2006 CD

CD |Gate-2013| Compiler Design

1. 12. 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 → є and A → a) to parse a string with n tokens? [GATE – 2013]

a. n/2
b. n-1
c. 2n-1
d. 2n

Answer  : b)


2. Consider the following two sets of LR(1) items of an LR(1) grammar.

X -> c.X, c/d
   X -> .cX, c/d
   X -> .d, c/d
   X -> c.X, $
   X -> .cX, $
   X -> .d, $

Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE? [GATE – 2013]

  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 c will lead to two different sets.

a. 1 only
b. 2 only
c. 1 and 4 only
d. 1,2,3 and 4

Answer : d)
CD |Gate-2013|


Back to GATE-HOME


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *