Site icon i2tutorials

Compiler Design-Syntax Directed Translation

Syntax Directed Translation

 

Grammar + Semantic Rules = SDT

      (SDD)

SDD: Syntax Directed Definition

Ex:

 E -> E + T E.val -> E.val + T.val

 E -> T E.val -> T.val

 

Attributes are associated with grammar symbols and the semantic rules are associated  with programs

If x is the symbol and a is one of its attribute then x.a idenote the value at node x.

Attributes may be number, string, references, data types etc.

 

Types of Attribute

     1. Synthesized Attributes

If a node takes value from its children then it is called synthesized attributes

Ex: A -> BCD

A.S = B.S

A.S = C.S

A.S = D.S

      2. Inherited Attributes

If a node takes value from its parent or siblings is called inherited attributes

Ex: A -> BCD

C.S = A.S

C.S = B.S

C.S = D.S

 

Reference Link

Syntax Directed Translation

Exit mobile version