edited by
3,784 views
27 votes
27 votes
  1. Construct all the parse trees corresponding to $i + j * k$ for the grammar
       $E \rightarrow E+E$
       $E \rightarrow E*E$
       $E \rightarrow id$
  2. In this grammar, what is the precedence of the two operators $*$ and $+$?
  3. If only one parse tree is desired for any string in the same language, what changes are to be made so that the resulting LALR(1) grammar is unambiguous?
edited by

1 Answer

Best answer
40 votes
40 votes
  1. two parse tree for i+j*k.
  2. $+$ and $*$ having same precedence..
  3. to make grammar LALR compatible give priority to $+$ over $*$ or vice versa.

following grammar is LALR(1)

$E \rightarrow  E + T$
$\qquad \mid T$
$T \rightarrow T * F$
$\qquad \mid F$
$F \rightarrow id$

edited by

Related questions

25 votes
25 votes
1 answer
3
Kathleen asked Sep 15, 2014
4,169 views
We require a four state automaton to recognize the regular expression $(a\mid b)^*abb$Give an NFA for this purposeGive a DFA for this purpose