[antlr-interest] Strange warnings

Jim Idle jimi at temporal-wave.com
Sun Jul 1 18:53:35 PDT 2007


Try:

  {(input.LA(1) == '\\' && ( input.LA(2) == ' ' || input.LA(2) ==
'\t'))}? '\\'
| etc.

The lexer is probably thinking that it does not need the predicate as
you have expressed it.

Epsilon means an empty alt:

fred	: X
	| // Epsilon
	;

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of David Piepgrass
> Sent: Sunday, July 01, 2007 12:06 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Strange warnings
> 
> I get some warnings related to this rule and I can't see why.
> 
> fragment PUNC_CHAR:
> 	  ('\\' WS_CHAR)=>'\\'
> 	| {input.LA(2) != '*' && input.LA(2) != '/'}? '/'
> 	| (':'|'.'|'~'|'!'|'@'|'$'|'%'|'^'|'&'
> 	  |'*'|'-'|'+'|'='|'|'|','|'<'|'>'|'?');
> PUNC: PUNC_CHAR+;
> 
> This rule says PUNC_CHAR can only match a backslash if it is followed
> by a space. So there should be no way PUNC can match input such as
> \\\! or \\\/.
> 


More information about the antlr-interest mailing list