Theory of Computation and Compilers - Syntax Analysis

31. An LALR(l) parser for a grammar G can have shift-reduce (S-R) conflicts if and only if

  • Option : B
  • Explanation :
    An LALR(1) parser for a grammar G can have shift reduce S – R conflict if and only if the LR(1) parser for G has S – R conflicts.
Cancel reply

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


Cancel reply

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


32. The grammar S → aSa |bS|c is

  • Option : C
  • Explanation :
    t is LL(1) and LR(1)
    because in S → aSa
    S → bS
    S → c

    no mult iple ent r ies for 1 iteration, so it is LL(1) grammer mean by LR(1) that it is Left shift
    Reduced grammer and so it is also LR(1).
    Hence it is both LL(1) and LR(1)
Cancel reply

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


Cancel reply

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


33. What is the maximum number of reduces moves that can be taken by a bottom up parser for a grammar without epsilon and limit productions (i.e. of type A → ε and A → a) to parse a string with n tokens?

  • Option : B
  • Explanation :
    As per given question, a grammar with no epsilon and unit -production (i.e., of type A → ε and A → a).
    So To Reduce input string of n tokens, first Reduce n – 2 tokens using n – 2 reduce moves and then Reduce last 2 tokens using production which has. So total of n – 2 + 1 = n – 1 Reduce moves
Cancel reply

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


Cancel reply

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


34. Consider the following two sets of LR(1) items of LR(1) grammar.
X → c.X, c/dX → c.X, $
X →.cX, c/dX → .cX, $
X → .d, c/d X → .d, $
Which of the following statement related to merging of the two sets in the corresponding 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 c will lead to two different sets.

  • Option : D
  • Explanation :
    (1) false, as merging has been done because lookahead were different.
    (2) false, Shift-Reduce conflict never occur at the time of merging.
    (3) false, In the merged set, we can’t see any Reduce-Reduce conflict (no reduction even possible, so no chances of R-R conflict )
    (4) false, because goto is carried on Non-Terminals symbols, not on terminal symbols, and c is a terminal symbol.
Cancel reply

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


Cancel reply

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


35. A canonical set of items is given below
S → L. > R
Q → R.
On input symbol > the set has

  • Option : D
  • Explanation :

    Form above diagram, we can see that there is no shift -reduce or reduce-reduce conflict .
Cancel reply

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


Cancel reply

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