1,591 views
0 0 votes
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 reach there, In a bottom up parser we will perform semantic action when reduction occurs.

I understood the above part, But when we have L-Attributed semnatic rules how and when they will get executed?  please explain or provide a source to read.

2 Answers

0 0 votes

@jaswanth431

S-attributed SDT If an SDT uses only synthesized attributes, it is called as S-attributed SDT.

These attributes are evaluated using S-attributed SDTs that have their semantic actions written after the production (right hand side)...

S-attributed SDT As depicted above, attributes in S-attributed SDTs are evaluated in bottom-up parsing, as the values of the parent nodes depend upon the values of the child nodes…

 

L-attributed SDT This form of SDT uses both synthesized and inherited attributes with restriction of not taking values from right siblings. In L-attributed SDTs, a non-terminal can get values from its parent, child, and sibling nodes….

As in the following production S → ABC S can take values from A, B, and C (synthesized).

A can take values from S only. B can take values from S and A. C can get values from S, A, and B.

No non-terminal can get values from the sibling to its right…

 

Attributes in L-attributed SDTs are evaluated by depth-first and left-to-right parsing manner. L-attributed SDT We may conclude that if a definition is S-attributed, then it is also L-attributed as L-attributed definition encloses S-attributed definitions...

 

1. https://cse.iitkgp.ac.in/~bivasm/notes/SDD.pdf 

 

2. https://nptel.ac.in/content/storage2/courses/106108113/module4/Lecture12.pdf 

 

3. https://www.cse.iitk.ac.in/users/swarnendu/courses/spring2020-cs335/Semantic%20Analysis.pdf 

 

4. https://www.csd.uwo.ca/~mmorenom/CS447/Lectures/Translation.html/node4.html 

 

5. https://gateoverflow.in/290789/Madeeasy-series-compiler-design-syntax-directed-translation 

 

6. https://gateoverflow.in/187007/L-and-s-attribute 

 

7. https://gateoverflow.in/169340/L-attributed-definition

 

 

 

0 0 votes
Depth first evaluation is used in L attributes.
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.8k
1.8k views
Na462 asked Oct 8, 2018
1,766 views
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 resul...
0 0 votes
1 1 answer
2.7k
2.7k views
radha gogia asked May 6, 2018
2,734 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('...
0 0 votes
1 answers 1 answer
641
641 views
atul_21 asked Nov 28, 2017
641 views
4 4 votes
0 0 answers
5.4k
5.4k views
saxena0612 asked Nov 12, 2017
5,355 views
I read from Dragon Book that Syntax directed translation is used for type checking for instance where performing some reductions and other operation on the string or symb...