GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
125 views

Consider the $SDTS$ for the ambiguous grammar

$E \rightarrow E + E$        $out ("1 + 2 ")$

$E \rightarrow E ^{*} E$         $out ("2 ^{*} 3")$

$E \rightarrow num$          $out (num.val)$

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 _______.

 

EDIT: Here's the explanation given..

 

asked in Compiler Design by Loyal (2.5k points)  
edited by | 125 views
@Amsar @Pooja @Arjun sir
@ Tushar, there r two possible Derivation trees ,

      one will give 112*311+2

      & other will give 1111 + 22 * 3
See the edit. And how can there be 2 answers? Its a numerical answer wala qstn..

1 Answer

+3 votes

The Grammar is ambiguous  .How can we assume a SR parser for ambiguous  Grammar .I don't think this question is Right. No Parse can parse the ambiguous  Grammar Except Operator Precedence Parse ( it can parse only some of the ambiguous  Grammar Not All )  as far as i  Know.

Answer : No Answer

answered by Veteran (41.1k points)  


Top Users Mar 2017
  1. rude

    4018 Points

  2. sh!va

    2994 Points

  3. Rahul Jain25

    2804 Points

  4. Kapil

    2606 Points

  5. Debashish Deka

    2092 Points

  6. 2018

    1414 Points

  7. Vignesh Sekar

    1318 Points

  8. Bikram

    1218 Points

  9. Akriti sood

    1166 Points

  10. Sanjay Sharma

    1004 Points

Monthly Topper: Rs. 500 gift card

21,439 questions
26,753 answers
60,919 comments
22,929 users