[antlr-interest] wildcard in tree grammar
Gavin Lambert
antlr at mirality.co.nz
Sun Nov 30 23:15:04 PST 2008
At 09:29 1/12/2008, Terence Parr wrote:
>not sure. I guess i left out as it's weird. When would you
write:
>
>^(. ID). It's always the root that says what kind of thing it
is,
>
>right?
This is a completely fabricated example, but your tree structure
might dictate that at that position you know it's either a
^(ORDER1FN ID) or a ^(ORDER2FN ID) or a ^(ORDER3FN ID). In one
tree grammar you care about the distinction, while in another you
don't.
Of course you could just write ^((ORDER1FN | ORDER2FN | ORDER3FN)
ID), but if you know that there will never be any other
possibilities then it's simpler to just write ^(. ID), especially
as the number of variations increases.
And then of course there's Oliver's example, where he just wanted
to traverse the (sub)tree regardless of structure (presumably to
pretty-print it or something).
They might be unusual cases, admittedly, but they seem reasonable.
More information about the antlr-interest
mailing list