"Mix-in" reduction-time code would be useful to allow auxiliary processing to be enabled or disabled (or run in a separate pass over the tree) as desired by the caller.
The labeling pass is the unch in the crunch here -- if both passes matched the same patterns then they could run independently. However, fully independent implementation is not always what's required; sometimes the auxiliary pass generates information for the main pass.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The labeling pass is the unch in the crunch here -- if both passes matched the same patterns then they could run independently. However, fully independent implementation is not always what's required; sometimes the auxiliary pass generates information for the main pass.
There is a very similar requirement to separate reduction logic from tree parsing logic.
One possible syntax is:
nonterminal = Pattern fooBar Reduction fooReduceRoutine;
Or, for ride-along annotations:
nonterminal = Pattern fooBar Annotation processFoo
{
return reduction_result;
}