[antlr-interest] v3: Error position is wrong when created in a decision for input.LA(>1)

Richard Musiol mail at richard-musiol.de
Sun Aug 20 05:34:25 PDT 2006


Hi,

I found another bug in version 3. When there is a decision for LA(>1) 
the NoViableAltException is still created for the first char. So in the 
following example the index of the nvae is one less than it should and 
the char is '<' (but there is nothing wrong with this char in this 
place). Please fix it. Thanks.

         int alt24=3;
         int LA24_0 = input.LA(1);
         if ( (LA24_0=='<') ) {
             int LA24_1 = input.LA(2);
             if ( (LA24_1=='!') ) {
                 [...]
             }
             else if ( [...] ) {
                 alt24=1;
             }
             else {
                 NoViableAltException nvae =
                     new NoViableAltException("...", 24, 1, input);
                 throw nvae;
             }
         }

Bye,
Richard


More information about the antlr-interest mailing list