GATE CSE
First time here? Checkout the FAQ!
x
+2 votes
174 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.7k points)  
edited by | 174 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 (42.9k points)  


Top Users Sep 2017
  1. Habibkhan

    6970 Points

  2. Warrior

    2490 Points

  3. Arjun

    2368 Points

  4. rishu_darkshadow

    2136 Points

  5. A_i_$_h

    2004 Points

  6. nikunj

    1980 Points

  7. makhdoom ghaya

    1760 Points

  8. manu00x

    1756 Points

  9. Bikram

    1744 Points

  10. SiddharthMahapatra

    1718 Points


26,060 questions
33,669 answers
79,747 comments
31,080 users