[antlr-interest] wildcard in tree grammar
Gavin Lambert
antlr at mirality.co.nz
Wed Nov 26 12:39:28 PST 2008
At 09:14 27/11/2008, Oliver Zeigermann wrote:
>Too bad for me as I have this in a tree parser (rule is spelled
>with 3xe on purpose):
>
>treee
> : ^(. treee* )
> ;
>
>which will never come to see the "treee*" part as the first "."
>matches the complete subtree making my analysis (code is left
out
>for clarity) defunct.
>
>Or am I missing something here (as usual).
I'm not sure how Ter ended up implementing it, but I don't think
there should be any problem with what you have here.
A wildcard in the 'root' position can only be a single node,
because you can't have a subtree as a root. So the meaning of the
above shouldn't have changed.
Although incidentally, I would expect the above to fail to match
if you have anything other than subtrees; ie. while it should
match this:
^(FOO ^(BAR ^(BAZ)) ^(WIBBLE))
I would expect it to fail to match this:
^(FOO ^(BAR BAZ) WIBBLE)
More information about the antlr-interest
mailing list