KEY FEATURES.
A TRANSLATION SCHEME is a context-free grammar in which semantic rules are embedded within the right sides of the productions.
|
(6) |
is the set of operators and
the set of values.
We assume that L is binary infix.
We associate to L a language L' of arithmetic expressions, binary postfix.
This is given by a map p defines as follows.
we have p(a) = a
we have
p(B f C) = B C f.
| Production | Semantic Rule |
|
A |
A.str := a |
|
A |
A.str := B.str |
|
A |
A.str := concat(B.str, C.str, " f") |
It is possible to speed up translations from L to L' by considering the following translation scheme.
| A |
|
a { output(a) } |
| A |
|
(B) { } |
| A |
|
B f C { output(f) } |
We illustrate the notions of syntax tree and translation scheme with the expression a + (a + d )*(b - c).