• edited by
1,779 views
0 0 votes

I know that every S attributed grammar is L attributed but not vice versa. Can anybody give example of the case if i print the semantic rules using L attributed the result will be different from the S attributed evaluation ? And how should i print the rules in both cases.

Explain both case in this example :

 

Consider the translation scheme shown below
$\mathrm{S} \rightarrow \mathrm{T} R$
$\mathrm{R} \rightarrow+\mathrm{T}$ \{print ('+'); $\} \mathrm{R} \mid \varepsilon$
$\mathrm{T} \rightarrow$ num \{print (num.val); $\}$
Here num is a token that represents an integer and num.val represents the corresponding integer value. For an input string ' $9+5+2$ ', this translation scheme will print
(Note: Use L-attributed evaluation to produce output)

  1. $9+5+2$
  2. $95+2+$
  3. $952++$
  4. ++952

1 Answer

0 0 votes
B is the ans
Position:
Show:

Related questions

2 2 votes
1 1 answer
1.8k
1.8k views
Mojo-Jojo asked Jan 17, 2016
1,825 views
Statement : L attributed grammer can be evaluated using bottom up parsing.Doubt : L attributed has both types, synthesized as well as left inherited grrammer. So in L att...
4 4 votes
2 answers 2 answers
5.2k
5.2k views
Purple asked Jan 27, 2016
5,194 views
How to solve this question?Attributes calculated from children are synthesized, while attributes calculated from parents and/or siblings is inherited. And S-attributed ar...
0 0 votes
2 2 answers
1.6k
1.6k views
jaswanth431 asked Nov 16, 2021
1,609 views
If the grammar has only S-attributed semantic definitions, in a top down parser we will add the semantic action at the end of production and it will we executed when we...
0 0 votes
1 1 answer
2.8k
2.8k views
radha gogia asked May 6, 2018
2,758 views
E->TE'E'->*T { printf('*') ;} E' | epsilonT- id {printf (id.name) ;}A) E->E*T | T {printf('*');}T->id {printf(id.name);}B) E->TE'E'->*TME' | epsilonM->epsilon { printf('...