[antlr-interest] Fwd: ANTLR 3.4 version Jul 19, 2011 Incorrectly transforms test grammar.

The Researcher researcher0x00 at gmail.com
Fri Sep 23 05:47:29 PDT 2011


Upon further investigation, matchRange('0','9');  will cause a compile error
because ranges are only allowed in lexer rules not parser rules.

Basically, ANTLR didn't give a error message when it should.

---------- Forwarded message ----------
From: The Researcher <researcher0x00 at gmail.com>
Date: Fri, Sep 23, 2011 at 8:19 AM
Subject: ANTLR 3.4 version Jul 19, 2011 Incorrectly transforms test grammar.
To: antlr-interest at antlr.org


The following demo grammar causes ANTLR 3.4 to generate an invalid parser.
The conditional for the if statement is empty.

grammar Demo002;
number  : '0'..'9';

java -classpath /usr/local/lib/antlr-3.4-complete.jar  org.antlr.Tool
Demo002

In Demo002Parser.java

            // Demo002.g:3:9: ( '0' .. '9' )
            // Demo002.g:
            {
            if (  ) {
                input.consume();
                state.errorRecovery=false;
            }
            else {
                MismatchedSetException mse = new
MismatchedSetException(null,input);
                throw mse;
            }

            }

java -classpath /usr/local/lib/antlr-3.3-complete.jar  org.antlr.Tool
Demo002.g

            // Demo002.g:3:9: ( '0' .. '9' )
            // Demo002.g:3:11: '0' .. '9'
            {
            matchRange('0','9');
            }


More information about the antlr-interest mailing list