[antlr-interest] Newbie : resolving ambiguity between "number" and "string"

Omry Yadan omry at yadan.net
Mon Feb 12 00:40:29 PST 2007


Hi,

I am trying to get my grammar (2.7.6)  to match the following :
12.3 : Number.
"12.3" : Number.
"abc" : String

I tried the following:
protected DOT : '.';
protected NUM : (DIGIT)+ ((DOT)(DIGIT)+)?;
NUMBER : NUM | "\""! NUM "\""!;
STRING : "\""! (~'"')* "\""!;

but as expected there is an ambiguity between string and number.
how can I express that the content of the a string may not be a NUMBER?

    Thanks,
       Omry.


More information about the antlr-interest mailing list