Here is a transliteration of Appel's initialization code (Modern Compiler Construction in Java, page 12), modified as discussed in Section 1:
This macro is invoked in definition 29.
Stm* prog =
new CompoundStm(
new AssignStm("a", new OpExp(new NumExp(5), new Plus(), new NumExp(3))),
new CompoundStm(
new AssignStm(
"b",
new EseqExp(
new PrintStm(
new PairExpList(
new IdExp("a"),
new LastExpList(
new EseqExp(
new PrintStm(
new LastExpList(
new OpExp(new IdExp("a"), new Minus(), new NumExp(5))
)
),
new OpExp(new IdExp("a"), new Minus(), new NumExp(1))
)
)
)
),
new OpExp(new NumExp(10), new Times(), new IdExp("a"))
)
),
new PrintStm(new LastExpList(new IdExp("b")))
)
);
Once the tree has been constructed, it can be interpreted by instantiating an interpreter and invoking the Accept method of the tree root:
This macro is invoked in definition 29.
Interpreter evaluate;
prog->Accept(&evaluate);
Termination of the Accept invocation indicates termination of the program being interpreted.