[antlr-interest] Reading a string of fixed size
Gavin Lambert
antlr at mirality.co.nz
Mon Aug 27 06:01:33 PDT 2007
At 22:24 27/08/2007, Edwards, Waverly wrote:
>The error:
>line 1:0 required (...)+ loop did not match anything at input
>'5:abcde'
[...]
>start : CAMI_STRING2
[...]
>CAMI_STRING : Digit+ ':' Letter AlphaNum*
[...]
>CAMI_STRING2 : Number ':' AlphaNumStr
This error is because you have both CAMI_STRING and CAMI_STRING2
in your lexer, and they conflict. The result is that the lexer
will be outputting CAMI_STRING tokens (since they both consume the
same amount, the first listed one wins), and your parser will only
accept CAMI_STRING2 tokens, which don't exist.
Comment out the CAMI_STRING rule and it should work.
(The important thing to bear in mind is that all lexing is done
before parsing begins. The parser cannot influence the lexer in
any way.)
More information about the antlr-interest
mailing list