[antlr-interest] wildcard in tree grammar
Oliver Zeigermann
oliver.zeigermann at gmail.com
Thu Nov 27 05:21:31 PST 2008
2008/11/27 Gavin Lambert <antlr at mirality.co.nz>:
> At 21:23 27/11/2008, Oliver Zeigermann wrote:
>>> 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*)
>>
>>Using these semantics my original rule
>>
>>tree : ^(. tree* ) ;
>>
>>would match any tree even if subtrees are single nodes
>>only, right?
>
> Right. That makes the most sense to me, since it keeps the structure
> consistent and treats a leaf node on the tree exactly the same as a parent
> node that simply happens to have no children at the moment (which is usually
> how it should be).
Right. Agreed.
@Terence: Is it like this? What do think? Should it be like that?
Oliver
More information about the antlr-interest
mailing list