Chapter 5:Semantic Analysis

Simulating the evaluation .

. Insert a marker M just before C in the second rule and change rules to

S aAC Ci = As
S bABMC Mi = As ; Ci = Ms
C c C s = g(Ci )
M ε M s = Mi

. When production M ε is applied we have M s = Mi = A s

. Therefore value of C i is always at [top-1]

If we insert a marker M just before C in the second rule and change rules to those given above. When production M -> ε is applied, a copy rule M.s = M.i ensures that we have M.s = M.i = A.s just before the part of the stack used for parsing the subtree for C. Therefore, value of C.i is always in val[top -1] when C -> c is applied, independent of first or second productions in transformed scheme being applied.