[antlr-interest] Problem with lexical nondeterminism - ANTLR 2.7.7

Gavin Lambert antlr at mirality.co.nz
Thu Jan 3 12:00:53 PST 2008


At 04:00 4/01/2008, Daniels, Troy \(US SSA\) wrote:

>The problem is that your rules are ambiguous with fixed 
>look-ahead, which is what antlr 2 uses.  Given 4 digits and k=4 
>look-ahead, either rule could match, hence the warning when 
>compiling the grammar.  You need a semantic predicate to 
>disambiguate it:
>
>APAC_NUMERIC_TICKER
>     : (DIGIT+ COMMA) => ((DIGIT)+ (COMMA) (CHAR) (CHAR))
>     ;

That's actually a syntactic predicate :)

But yeah, that should do the trick.  Although you don't need that 
many parentheses.  You may also need to make sure that 
APAC_NUMERIC_TICKER is listed before NUMBER in the grammar file.



More information about the antlr-interest mailing list