[antlr-interest] ANTLR grammar processing returns strange warnings
gerald at certiv.net
Wed May 20 08:42:02 PDT 2009
The warning is correct.
can conflict with
T_MACADDR :S_HEX ...
fragment S_HEX :('0'..'9' | 'a'..'f' | 'A'..'F');
which could be just a single character 'E'
Warnings go away if you change S_HEX to
:('0'..'9' | 'a'..'f' | 'A'..'F') ('0'..'9' | 'a'..'f' | 'A'..'F');
(you will need to change other rules accordingly)
Using sample input, you can generate the token stream and verify the
actual path the lexer is taking.
At 01:50 AM 5/20/2009, you wrote:
>Dear ANTLR users,
>I am a happy (until now) new user of ANTLR. I learned ANTLR from
>scratch by reading the "The Definitive ANTLR Reference" book and
>trying to code a configuration file parser with ANTLR 3.1.3.
>While coding the grammar, I had no problem for converting grammar into
>Java until a certain moment, where I get lots of warnings similar to
>"warning(209): TestKO.g:450:1: Multiple token rules can match input
>such as "'T'" : ID_TFTPTIMESTAMP, ID_TFTPMODEMADDRESS,
>ID_TESTMODEENABLE, ID_TEKGRACETIME, SNMP_TIMETICKS, T_OID"
>Typically, with TestOK.g grammar, conversion works. With TestKO.g
>grammar, conversion returns warnings (see error.txt file).
>I can't understand why these warnings are returned as - I think -
>there is no errors in my grammar (lots of warning lines are returned
>against lines that were unmodified between TestOK and TestKO !).
>May you have some feedbacks if this is finally a mistake in my grammar
>(any advice is welcome, as I mentionned it is my first experience with
>ANTLR) or is it known problems with ANTLR (I read some threads on
>ANTLR interest mailing list with the same warnings, but it seems this
>is not the same situation).
>Content-Type: text/plain; charset=US-ASCII; name="error.txt"
>Content-Disposition: attachment; filename="error.txt"
>Content-Type: application/octet-stream; name="TestOK.g"
>Content-Disposition: attachment; filename="TestOK.g"
>Content-Type: application/octet-stream; name="TestKO.g"
>Content-Disposition: attachment; filename="TestKO.g"
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest