Consider creating an intermediate AST
Codegen is currently done in one pass. It may be easier to maintain by splitting into an intermediate AST for the non-leaf elements (i.e. keep Lit
,Term
etc., but replace Stat
with e.g. Message
tree and Service
tree etc.), and then folding over that on a second pass and transforming the intermediate ASTs into meta.Stat
s.