Next: Exercise 2.
Up: Quiz2
Previous: Guidelines.
We consider the following syntax-directed definition
with nonterminals B and D, terminals 0 and 1
and attributes B.pos, B.val, D.pow and D.val.
Production |
Semantic Rule |
B DB1 |
B.pos :=
B1.pos + 1 |
|
B.val :=
B1.val + D.val |
|
D.pow := B1.pos |
B D |
B.pos := 1 |
|
B.val := D.val |
|
D.pow := 0 |
D 0 |
D.val := 0 |
D 1 |
D.val := 2D.pow |
Is the above syntax-directed definition L-attributed?
Give a parse tree for w = 10.
Then compute the attributes at each node.
Answer 1
Figure 1:
The decorated parse tree for w = 10.
|
Next: Exercise 2.
Up: Quiz2
Previous: Guidelines.
Marc Moreno Maza
2004-12-02