[antlr-interest] Lexer rules and unreachable alternatives (trying to understand lexer)

Wincent Colaiuta win at wincent.com
Thu Apr 19 03:07:51 PDT 2007


Given a lexer with a single rule:

	OTHER : .+ ;

Why would ANTLR issue this warning?

	warning(201): T.g:8:9: The following alternatives are unreachable: 1

The warning goes away if I instead write:

	OTHER : .* ;

Looking at the syntax diagram in ANTLRWorks I see something like this:

	 /-------------------------\
	v                           |
OTHER -------> '\u0000'..'\uFFFE' ---===>

The final part of the rightmost arrow is highlighted in red.

If I write the rule like this, the warning goes away:

	OTHER : '\u0000'..'\uFFFE'+ ;

What am I misunderstanding here?

Cheers,
Wincent



More information about the antlr-interest mailing list