In Helvetia
there is a different implementation of PPCompositeParser
that works with the same grammar source but compiles variable accesses
to use a dictionary instead. This then scales to an almost infinite
number of productions. I agree that introducing the Helvetia
dependendency is not feasible though.
Well, it might be feasible for me :) I downloaded the Helvetia one-click and
couldn't find the different impementation of PPCompositeParser.
CUCompositeParser. It performs a series of transformations on all
production methods, so
1. it automatically adds the return statement
2. it automatically converts literals to their respective parsers
3. it automatically converts variable accesses to dictionary accesses
I wonder if we
could use some other trick that wouldn't require a
custom compiler and that would work across platforms?
That would be wonderful. The only cross-platform trick that I know is adding
"self" in front of a ruleName :)
That has different semantics, so I don't think that this is a good solution.
If you don't mind writing something like
self @ #otherProd
or with some heavy meta-programming
#otherProd ref
to refer to other productions, one could use the dictionary approach
from the Helvetia image. With a rewrite rule you could quickly fix the
existing code.
Lukas
--
Lukas Renggli
www.lukas-renggli.ch