|Contents | Language Implementations | Perl6|
Post-process the parse tree into the form used by the rest of the compiler.
This is faster than making a neat parse tree directly.
Each parse tree node class (i.e.
grammar rule) should define a
tree function that takes a raw parse tree node,
and returns a processed one.
Both of these objects are blessed into the same class (don't call tree on a processed node,
or val on a raw one,
or bad things will happen).
See Nodes.pm for descriptions of the various nodes -- there's mostly a one-to-one correspondence between them and the grammar rules,
but a few of the rules that got inlined away reappear as node types,
while some of the lower-level rules are not preserved.
Remember to update the appropriate tree function here if you change the grammar. The functions here appear in roughly the same order as the grammar rules in Parser.pm.
$nodeif appropriate. Useful for handling optional items and rules with empty alternations.
treeon each of its elements.