[antlr-interest] Lexing problem I cannot resolve

Gavin Lambert antlr at mirality.co.nz
Thu Aug 7 05:39:15 PDT 2008


At 14:27 7/08/2008, Thomas Brandon wrote:
 >The portion ( (DOTDOT) => | ( '.' DIGIT* { $type = FLOAT; } )? )
 >produces the code like (under 3.1b2 and similar under 3.0.1):
 >if ( (LA4_0=='.') ) {
 >    alt4=2;
 >}
 >else if ( (synpred1_test()) ) {
 >    alt4=1;
 >}
 >I gather due to ANTLR trying to only inserts predicates when 
there
 >is syntactic ambiguity. Changing it to ( ('.' ~'.')=> '.' DIGIT*
 >{$type=FLOAT;} )? fixes this. Or ('.' DIGIT)=> '.' DIGIT+
 >{$type=FLOAT;} )? if you don' want to allow 1. as a FLOAT.

Ah, yes, you're right.  I keep forgetting about that little quirk 
:)



More information about the antlr-interest mailing list