Term Paper Group - 7 Bottom Up Evolution of Inherited Attributes
Term Paper Group - 7 Bottom Up Evolution of Inherited Attributes
Term Paper Group - 7 Bottom Up Evolution of Inherited Attributes
INHERITED ATTRIBUTES
Bachelor of Technology
Computer Science and Engineering
Submitted By
MONTH 2021
1. Abstract Page_3
2. Introduction Page_3-4
3. Body
I. Kind of Attributes for Non-Terminals Page_4
Ii. Inherited Attributes Page_4
Iii. Bottom-up Evalution of Inherited Attributes Page_4-5
Iv. Inherited Attributes on Parsar Stack Page_5
4. Conclusion Page_6
5. References Page-_6
TISL/CSE/Term-Paper/Semester- 2
1. Abstract
Attribute Grammars were invented by Don Knuth as a way to unify all of the stages of compiling into one. They give a
formal way to pass semantic information (types, values, etc.) around a parse tree.
We now allow any grammar symbol X to have attributes. The attribute a of symbol X is denoted X.a
If there is a grammar rule
then a semantic rule for P computes the value of some attribute of one of the Xi in terms of other attributes
of symbols in the rule.
If you think of the rule as forming the node of a tree, an attribute of a node gets its value from the attribute
of its parent, siblings and children (but not from its grandparent).
2. Introduction
A syntax - directed definition (SDD) is a context-free grammar together with attributes and
rules Attributes are associated with grammar symbols and rules are associated with
productions. If X is a symbol and a is one of its attributes, then we write to denote the value
of a at a particular parse-tree node labeled X If we implement the nodes of the parse tree
by records or objects, then the attributes of X can be implemented by data fields in the
records that represent the nodes for X. Attributes may be of any kind. Numbers, types,
table references, or strings, for instance. The strings may even be long sequences of code,
say code in the intermediate language used by a compiler.
TISL/CSE/Term-Paper/Semester- 3
3. Body
INHERITED ATTRIBUTES
TISL/CSE/Term-Paper/Semester- 4
BOTTOM-UP EVALUTION OF INHERITED ATTRIBUTED
Removing Embedding Semantic Actions, in bottom-up evaluation scheme, the
semantic actions are evaluated during reductions.
During the bottom-up evaluation of S-attributed definitions, we have a parallel
stack to hold synthesized attributes.
Problem: where are we going to hold inherited attributes?
A Solution: We will convert our grammar to an equivalent grammar to guarantee to the
followings -
6. All embedding semantic actions in our translation scheme will be moved into the
end of the production rules.
7. All inherited attributes will be copied into the synthesized attributes (most of the
time synthesized attributes of new non-terminals).
8. Thus, we will be evaluating all semantic actions during reductions, and we find a
place to store an inherited attribute.
TISL/CSE/Term-Paper/Semester- 5
4. Conclusion
In this PPT we have learnt about attributes grammar which was invented by Don Knuth
then we knew about Syntax directed definition and types of attributes for non-terminal
which is synthesized attribute and inherited attributes and then we learnt about bottom-up
evaluation of inherited attributes.
Using a bottom-up translation scheme, we can implement any L-attributed definition based
on LL (1) grammar.
5. References
https://cs.stackexchange.com/questions/67956/bottom-up-evaluation-of-inherited-
attributes
https://www.academia.edu/41864140/BOTTOM_UP_EVALUATION_OF_S_ATTRIBU
TED_DEFINITION
https://www.geeksforgeeks.org/differences-between-synthesized-and-inherited-attributes/
TISL/CSE/Term-Paper/Semester- 6