Phrogz wrote:
> For the archives, the original PEG/packrat paper defines:
>  EndOfFile <- !

That would be a good thing to add, and I think the meta-grammar
would still parse.

> In Treetop, this is obviated by the
> Treetop::Runtime::CompiledParser#consume_all_input flag, which
> defaults to true. Only by setting it to false do you get the
> (dubiously useful) behavior of ignoring the rest of the input if
> you've matched the root rule.

I use this in a loop to consume all the individual declarations in
a CQL file, because I need to act on each one in turn - I don't want
to process an entire file in one pass, with the possibility of a
syntax error backtracking through all the input and every parse
rule being memoized. But then, perhaps my "parse_all" method should
be added to Treetop, and then the flag wouldn't be as necessary.

I think Nathan would oppose it, but I'd also like to add regex's
as terminals for performance, so that a SyntaxNode isn't needed for
every character.

I've also suggested to him that certain rules could be designated as
"skip" rules, for which no SyntaxNode is built. Perhaps also that
a normal rule could identify another rule as a skip rule, which is
implicitly inserted between (but not around) each node of this rule.
This would allow such rules to implement the whitespace behaviour of
other parser generators, and perhaps also to build lists. Something
like:

rule statement skip whitespace
   'if' expression statement ( 'else' statement )?
    / etc...
end

where the whitespace rule is implicitly inserted, or

rule parameter_list skip comma_white
    item+
end

which would function as if I'd said

    item (comma_white item)*

Clifford Heath.