Professional Documents
Culture Documents
BKS Unit II-Synthesized and Inherited Atributes
BKS Unit II-Synthesized and Inherited Atributes
Unit II
– Predictive Parsing
– Bottom Up Parsing
– Operator Precedence Parsing
– LR Parsers
• SLR,
• LALR
• LR
• Parser Generator
Learn Compiler Design: From B K Sharma
Types of Attributes
1. Synthesized Attributes:
2. Inherited Attributes:
Learn Compiler Design: From B K Sharma
Synthesized Attributes:
A Synthesized attribute is an attribute of the non-
terminal on the left-hand side of a production.
A → B C
The attribute can take value only from its children
(Variables in the RHS of the production) or itself.
Synthesized Attributes:
Synthesized Attributes values are computed from the
values of the attributes of the children nodes or itself.
A → B C
Synthesized Attributes:
Annotated Parse Tree for
3 * 5 + 4 n
Learn Compiler Design: From B K Sharma
Inherited Attributes:
An attribute of a non-terminal on the right-hand side of a
production is called an inherited attribute.
A → B C
B
B’s attribute is dependent on A’s
attributes or C’s attributes then it will
val be inherited attribute.
Inherited Attributes:
Parse Tree
Learn Compiler Design: From B K Sharma
Inherited Attributes:
2. Inherited Attributes: Annotated Parse Tree for 3*5
Learn Compiler Design: From B K Sharma
Inherited Attributes:
2. Inherited Attributes: Annotated Parse Tree for 3*5
Learn Compiler Design: From B K Sharma