] > Syntax-Directed Translation Schemes (SDTS’s)

#### 5.1 Syntax-Directed Translation Schemes (SDTS’s)

• A Syntax-directed translation scheme is an extension of a context free grammar that describes the process of translating input strings into output strings.
• The scheme associates to each production rule of the source context free language a production rule of the target context free language.

$A\to \alpha ,\beta$

• $\alpha$ is called the source element of the rule
• $\beta$ is called the translation elementof the rule
• There is 1-1 correspondence between the nonterminal symbols of $\alpha$ and $\beta$
• A translation form is a pair $\left(u,v\right)$ where
• $u$ is a sentential form of the underlying grammar
• $v$ is the translation resulted by the derivation of $u$
 E $\to$ E + T, T E + $\to$ T, T T $\to$ T * F, F T * $\to$ F, F F $\to$ a , a
 E,E $⇒$ E + T, T E + $⇒$ T + T, T T + $⇒$ F + T, T F + $⇒$ ${a}_{1}$ + T, T ${a}_{1}$ + $⇒$ ${a}_{1}$ + T * F, F T * ${a}_{1}$ + $⇒$ ${a}_{1}$ + F * F, F F * ${a}_{1}$ + $⇒$ ${a}_{1}$ + ${a}_{2}$ * F, F ${a}_{2}$ * ${a}_{1}$ + $⇒$ ${a}_{1}$ + ${a}_{2}$ * ${a}_{3}$, ${a}_{3}$ ${a}_{2}$ * ${a}_{1}$ +
• Note that the parse trees of the source and target strings relate the same way to the nonterminal symbols, up to permutations in their orderings.