[antlr-interest] wildcard string in grammar

Gavin Lambert antlr at mirality.co.nz
Wed Jul 22 12:58:15 PDT 2009


At 03:06 23/07/2009, Tim Williams wrote:
 >WILD_STRING: (('a'..'z'|'A'..'Z')* ('*'|'?')
 >('a'..'z'|'A'..'Z')*)+
 >
 >This generates the warning "Decision can match input
 >('a'..'z'|'A'..'Z') using multiple alternatives 1,2 disabling
 >alternative(s) 2."

WILD_STRING
   : ('a'..'z'|'A'..'Z')*
     (
       ('*'|'?')
       ('a'..'z'|'A'..'Z')*
     )+
   ;

This might end up being ambiguous with an ID-style rule, though, 
since the lexer doesn't always look far enough ahead to deal with 
distinguishing characters after loops.



More information about the antlr-interest mailing list