[antlr-interest] Re: Semantic predicates that aren't & hoisting

John D. Mitchell johnm-antlr at non.net
Mon Mar 14 16:09:42 PST 2005


>>>>> "David" == David Jung <jungdl at ornl.gov> writes:
[...]

> That could be fixed by putting statementList in primaryExpr, but would
> introduce ambiguity.  Doing that would give something very similar to the
> solution I proposed in my original post in this thread.  However, my
> original question was if there was a better way; one that avoids the
> ambiguity.  Now I know the answer is no.  Perhaps ANTLR 3 will support
> the hoisting I need.

As the man once said, "You're deluded, Mr. Bond."

(A) As I've shown from the beginning, you can get around the lack of
hoisting by making your grammar a bit [or a lot depending on how ambiguous
your language is] more complicated so as to drive the decision more
directly.  This is what we had to do in the C grammar because Antlr v2
doesn't support automatic predicate hoisting.

(B) Your language looks pretty ambiguous.  One way or another you still
have to resolve the ambiguity by forcing the choice of how the parser will
actually act when it comes to those decision points.  There's no magic wand
to take that responsibility off of your hands as the language
designer/implementor.

(C) Yes, Antlr v3 does/will do automatic predicate hoisting.  This allows
for more naturally structured grammars.

Take care,
	John


More information about the antlr-interest mailing list