/    /  Compiler Design-Types of SDD

Types of SDD

     1. S – attributed SDD or S attributed Grammar

L – attributed SDD or L attributed Grammar

     2. S – attributed SDD – synthesized

L – attributed SDD – synthesized/ inherited

 

S – attributed SDD

A SDD that uses only synthesized attributes is called a S – attributed SDD

Ex: A -> BCD

A.S = B.S

A.S = C.S

A.S = D.S

Semantic actions are always placed at the right end of the production. It is also a postfix SDD.

Attributes are evaluated using bottom up passing

 

L – attributed SDD

A SDD that uses both synthesized and inherited attributes is called a L – attributed SDD but each inherited attribute is restricted to inherits from parent or left sibling

Ex: A – > BCD

C.S = A.S

C.S = B.S

C.S = D.S

Semantic actions are placed anywhere on the right hand side.

Attributes are evaluated by traversing parse tree depth first, left to right.

 

Reference Link

Types of SDD