Scheme to implement translation
. E has attributes truelist and falselist
. L and S have a list of unfilled quadruples to be filled by backpatching
. S while E do S 1
requires labels S.begin and E.true
- markers M1 and M2 record these labels
S while M 1E do M 2 S1
- when while. .. is reduced to S
backpatch S 1 .nextlist to make target of all the statements to
M 1 .quad
- E.truelist is backpatched to go to the beginning of S 1 (M 2 .quad)
E has attributes truelist and falselist. L and S have a list of unfilled quadruples to be filled by backpatching.
For example consider S while E do S1
M 1and M 2are used to record the quad numbers of S.begin and E.true respectively. B ackpatching is used to ensure that all targets on S 1 . nextlist are M 1 .quad. E.truelist is back-patched to go to the beginning of S 1 by making jumps on E.truelist targeted towards M 2 .quad. A n explicit jump to the beginning of the code for E is appended after the code for S1 to prevent control from "falling out the bottom".
|