0
6.0kviews
Syntax directed Translation

Mumbai University > Computer > Sem 6 > System Programming and Compiler Construction

Marks: 05

Year:DEC 16

1 Answer
0
136views

SDD: Specifies the values of attributes by associating semantic rules with the productions.

SDT scheme: embeds program fragments (also called semantic actions) within production bodies.

The position of the action defines the order in which the action is executed (in the middle of production or end).

SDD is easier to read; easy for specification.

SDT scheme – can be more efficient; easy for implementation

Overview

1 Construct a parse tree

2 Compute the values of the attributes at the nodes of the tree by visiting the tree

Key:

We don’t need to build a parse tree all the time.

Translation can be done during parsing.

class of SDTs called “L-attributed translations”.

class of SDTs called “S-attributed translations”.

Syntax Directed Translation

Attach rules or program fragments to productions in a grammar.

Syntax directed definition (SDD)

E1 → E2 +T E1.code = E2.code||T.code||’+’

Syntax directed translation Scheme (SDT)

E → E +T {print ’+’} // semantic action

F → id {print id.val}

Please log in to add an answer.