1 1 vote Given solution: After reducing two 1's of expression to E, E*E should be reduced not the 3rd 1. So final output will be 112*311+2 instead of the given output. Please check.Consider the SDTS for the ambiguous grammar \[ \begin{array}{ll} \mathrm{E} \rightarrow \mathrm{E}+\mathrm{E} & \text { out(" } \left.1+2^{\prime \prime}\right) \\ \mathrm{E} \rightarrow \mathrm{E} * \mathrm{E} & \text { out("2*3") } \\ \mathrm{E} \rightarrow \text { num } & \text { out(num. val) } \end{array} \] Assume a shift reduce parser. The output is treated as an arithmetic expression in C \& evaluated. The input is $1 * 1+1$. The value obtained is $\qquad$ .$1112 * 31+2=34474$ Compiler Design compiler-design parsing test-series + – shikharV 2.3k views answer comment Share Follow Print See 1 comment 1 1 comment reply amarVashishth commented Jan 19, 2016 reply Follow flag Grammar is ambiguous; There is no LR or LL parser for an ambiguous grammar, this question is flawed. 2 2 replyShare Please log in or register to add a comment.
1 1 vote Bottom Up Parsing = http://dragonbook.stanford.edu/lecture-notes/Stanford-CS143/08-Bottom-Up-Parsing.pdf amarVashishth answered Jan 19, 2016 amarVashishth comment Share Follow See all 2 Comments 2 2 Comments reply Vishal Goyal commented May 22, 2017 reply Follow flag can u please solve the above question iam not able to get the above parse tree can u explain in detail please 0 0 replyShare LeenSharma commented May 22, 2017 reply Follow flag Vishal Goyal Question is incorrect. There is two possible parse tree for 1*1+1.Both parse tree will give a different result.Given grammar is ambiguous and no LL or LR parser can parse ambiguous grammar. 0 0 replyShare Please log in or register to add a comment.