[antlr-interest] Error in produced lexer
    Alex Shneyderman 
    a.shneyderman at gmail.com
       
    Tue May 15 08:34:46 PDT 2007
    
    
  
I am on 3.0b7 of ANTLR and was trying to learn about syntactic
predicates today. So, I have the lexer described as so:
lexer grammar Disambiguation;
@lexer::header {
package antlrlist;
}
FLOATORINT
	: (DIGIT+ '.' DIGIT)  => DIGIT+ '.' DIGIT+
	| DIGIT+
	;
fragment DIGIT	: '0'..'9';
after I run Tool the lexer gets generated and no errors are reported
but the generated java is not valid. It has method like this:
    // $ANTLR start synpred1
    public final void synpred1_fragment() throws RecognitionException {
        // Disambiguation.g:17:4: ( ( DIGIT )+ '.' DIGIT )
        // Disambiguation.g:17:5: ( DIGIT )+ '.' DIGIT
        {
        // Disambiguation.g:17:5: ( DIGIT )+
        int cnt=0;
        loop:
        do {
            int alt=;
            switch (alt) {
        	case 1 :
        	    // Disambiguation.g:17:5: DIGIT
        	    {
        	    mDIGIT(); if (failed) return ;
        	    }
        	    break;
        	default :
        	    if ( cnt >= 1 ) break loop;
        	    if (backtracking>0) {failed=true; return ;}
                    EarlyExitException eee =
                        new EarlyExitException(, input);
                    throw eee;
            }
            cnt++;
        } while (true);
        match('.'); if (failed) return ;
        mDIGIT(); if (failed) return ;
        }
    }
    // $ANTLR end synpred1
which is not a valid java.
Anyone knows how to fix this?
-- 
Thanks,
Alex.
    
    
More information about the antlr-interest
mailing list