[antlr-interest] wildcard in tree grammar
Gavin Lambert
antlr at mirality.co.nz
Wed Nov 26 23:08:27 PST 2008
At 11:47 27/11/2008, Sam Harwell wrote:
>Note that when w.ChildIndex == 0 and its next sibling is EOA, it
>means the . is the child of a closure such as .* , since the
other
>possibility ^(.) is not allowed in a tree parser.
Why would "^(.)" not be allowed? That should simply match any
node with no children. I don't think there's any other syntax
that could express that particular condition (barring a semantic
predicate of course), as the equivalent 3.0 construct (simply ".")
now represents any node with any number of children.
I'm not sure it's an especially *useful* construct, but it ought
to be supported for consistency at least.
In other words (in vaguely ANTLR-like syntax):
wildtree : ANYNODE | ^(ANYNODE wildtree*) ;
. => wild
^(.) => ANYNODE
^(. FOO) => ^(ANYNODE FOO)
^(FOO .) => ^(FOO wildtree)
^(FOO . .) => ^(FOO wildtree wildtree)
^(FOO .+) => ^(FOO wildtree+)
^(FOO .*) => ^(FOO wildtree*)
To put it another way, given a single node FOO, all of the
following should be able to match it:
FOO
^(FOO)
^(FOO BAR?)
^(FOO xyz*)
.
^(.)
^(. BAR?)
^(. xyz*)
More information about the antlr-interest
mailing list