Hello, I had a grammar written in Antlr 3 and I am getting
EarlyExitExceptions.
This grammar attempts to match things like:

"[1..3]", "[ 1 .. 3]", "[ 1 .. x ]", "[x..1]", etc.

However, when provided  "[1..3]", it exits with an EarlyExitException.
line 1:3 required (...)+ loop did not match anything at character '.'
MismatchedTokenException(5!=7)
line 1:5 mismatched input ']' expecting TO

I believe it is a problem related to float parsing. The remaining examples
are parsed properly.
How do I prevent this problem?

I managed to simplify the grammar and reduce it to the following(the
original grammar is a lot more complex since it has support for other
statements):

//GRAMMAR STARTS HERE
grammar MyGrammarName;

options{
    backtrack = true;
    output = AST;
}

tokens{
    LARRAY = '[';
    RARRAY = ']';
    DOT = '.';
    TO = '..'; //I've tried declaring TO before DOT, declaring TO as a
separate rule and several variations.
}

@header{

package javapackage;

}

@lexer::header{

package javapackage;

}

test    :    LARRAY exp TO exp RARRAY;

exp    :    WORD|constant;

constant:    INTCONST|FLOATCONST;

WORD    :    ALPHA ALPHADIGIT*;

fragment ALPHA
    :    ('a'..'z')|('A'..'Z')|'_';

fragment ALPHADIGIT
    :    ALPHA|DIGIT;

FLOATCONST
    :
        (DIGIT+ ('e'|'E') '-'? DIGIT+)
    |        (DIGIT* DOT DIGIT+ (('e'|'E') '-'? DIGIT+)?)
    ;

INTCONST:    (NONZERODIGIT DIGIT*);

fragment NONZERODIGIT
    :    '1'..'9';

fragment DIGIT
    :    '0'|NONZERODIGIT;


IGNORED    :    (WS|LINEBREAK)+
        { $channel = HIDDEN; };

fragment LINEBREAK
    :    '\u000D'
    |    '\n'
        ;

fragment WS : (' ' | '\t' | '\f')+;

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to