[antlr-interest] ANTLR should warn about nullable tokens

Randall R Schulz rschulz at sonic.net
Mon Jun 25 16:57:05 PDT 2007


On Monday 25 June 2007 16:44, David Piepgrass wrote:
> I was testing my lexer on an invalid input when it entered an
> infinite loop.
>
> It turns out this was because of my whitepace rule:
>
> WS: (' '|'\t'|'\n'|'\r'|'\u000C')* { $channel=HIDDEN; };
>
> Which caused an infinite sequence of WS tokens. It should be
>
> WS: (' '|'\t'|'\n'|'\r'|'\u000C')+ { $channel=HIDDEN; };
>
> IMO, ANTLR should give a warning about this.


It's probably inappropriate to put such heuristic diagnostics into the 
ANTLR compiler generator itself.

Perhaps it's time for a lint- / PMD-style tool for ANTLR?


Randall Schulz


More information about the antlr-interest mailing list