The Gateway to Computer Science Excellence
0 votes
116 views
E->TE'

E'->*T { printf('*') ;}  E' | epsilon

T-> id {printf (id.name) ;}

A) E->E*T | T {printf('*');}

T->id {printf(id.name);}

B) E->TE'

E'->*TME' | epsilon

M->epsilon { printf('*');}

T->id {printf(id.name) ; }

 

C) E->T*E {printf('*');}

E->T

T->id {printf (id.name) ;}

D) None of these  

 

Please explain precisely .
in Compiler Design by Loyal (6.3k points) | 116 views
0

Refer this

0

And this

1 Answer

0 votes

In case of L attributed definition the semantic action is embedded to the immediate left of the non-terminal in a production. In case of S attributed definition the semantic action is embedded at the end of a production

As bottom up parsers cannot handle L attributed definitions so we convert L attributed definitions to S attribute definitions

How we do it?

By introducing a redundant non-terminal

Given grammar

E->TE'

E'->*T { printf('*') ;}  E' | epsilon

T-> id {printf (id.name) ;}

the highlighted semantic action is not placed in the end of the production. so it is not S attributed. Remaining are S attributed

E->TE'

E'->*T M  E' | epsilon

M->epsilon { printf('*') ;}

T-> id {printf (id.name) ;}

Both the grammars are equivalent

Option B is correct

by Active (5.1k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,616 answers
195,897 comments
102,355 users