Email list hosting service & mailing list manager


Re: More comments, and the ANTLR code is too complex David A. Wheeler 13 Jun 2013 13:13 UTC

Mark H Weaver <xxxxxx@netris.org> wrote:
> For example, constraining yourself to an LL(1) grammar probably rules
> out a more elegant presentation.

Hmm, I've always heard complaints about grammars that are NOT LL(1).
The obvious way to make sure it's LL(1)... is to specify it as LL(1).

> Another big problem is the amount of redundancy in this grammar.

We can look for that, at least!

> I suspect that the key to simplifying this grammar (apart from moving
> away from ANTLR for purposes of the specification) is to choose a
> different set of non-terminals.

That may be true, but I'm not sure what they would be.
I'll have to think about it, and if you have any other specific examples,
please post!

> One more nit while I'm on this subject: In the BNF conventions section,
> you write "a sweet-expression reader MUST act as if it preprocessed its
> input as follows", but as far as I can tell it's not actually possible
> to implement this as a preprocessor.  This "preprocessing" must be
> interleaved with parser, because several syntactic elements affect the
> preprocessing.  For example, the <* and *> markers manipulate the
> preprocessor's stack, and yet you need a full parser to recognize those
> markers.

You don't need a full parser.  ANTLR, for example, really does do
manipulations of the parsing stack in its *lexer* when it sees <* and *>.
In fact, there's no way in ANTLR for the parser to send messages back
to the lexer; ANTLR lexes the entire stream before it calls the parser.

I appreciate the comments.  I'll have to think about this some more.

--- David A. Wheeler