[antlr-interest] ANTLR 3(ea8) TreeNodeStream DOWN & UP insertion question.

Terence Parr parrt at cs.usfca.edu
Mon May 22 13:59:21 PDT 2006


On May 22, 2006, at 12:07 PM, Anthony Harrison wrote:

> I'm not sure if this is a bug or just a general misunderstanding on my
> part, but something seems wonky when running a tree parser over a tree
> that only has optional children.

You're right!  It's wonky.  From my bug list:

o ^(ROOT ID?) doesn't work.

> Specifically, something like ^(ROOT
> OPTIONAL_CHILD*) will throw mismatches when no children are present
> because DOWN & UP are not being inserted by the TreeNodeStream.

yep, same thing.

I continue by saying:

generate:

ROOT (DOWN alpha UP)?

rather than

ROOT DOWN alpha UP

if it sees possibility, but *only* if it sees a nullable child list.
This is a code gen issue not a NFA alteration.  Can just add a

if ( input.LA(1)==DOWN ) {
   match(DOWN);
   alpha
   match(UP);
}

I know the fix, but didn't get it into 3.0ea9...sorry!

Ter


More information about the antlr-interest mailing list