Simulating the evaluation .
. Markers can also be used to simulate rules that are not copy rules
S aAC |
Ci = f(A.s)
|
. using a marker
|
|
S aANC |
Ni = A s ; Ci = Ns
|
N ε |
N s = f(N i )
|
Markers can also be used to simulate rules that are not copy rules. For example, consider
PRODUCTION |
SEMANTIC RULES
|
S -> aAC |
C.i = f(A.s)
|
The rule defining C.i is not a copy rule, so the value of C.i is not already in the stack. To solve this problem this scheme is transformed into the following scheme, using a Marker
PRODUCTION |
SEMANTIC RULES
|
S -> aANC |
N.i = A.s; C.i = N.s
|
N -> ε |
N.s = f(N.i)
|
N inherits A.s by a copy rule. Its synthesized attribute N.s is set to f(A.s); then C.i inherits this value using a copy rule. When we reduce by N - > ε , we find the value of N.i in the place for A.s, i.e., in val[top - 1]. When we reduce by S -> aANC, we get the value of C.i in the place for N.s, i.e., in val [top - 1].
|