[antlr-interest] wildcard in tree grammar
    Oliver Zeigermann 
    oliver.zeigermann at gmail.com
       
    Thu Nov 27 00:23:40 PST 2008
    
    
  
2008/11/27 Gavin Lambert <antlr at mirality.co.nz>:
> 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?
Oliver
    
    
More information about the antlr-interest
mailing list