[antlr-interest] V3 unicode.g
Kay Roepke
kroepke at classdump.org
Wed Nov 22 12:24:21 PST 2006
On 22. Nov 2006, at 21:21 , Christian CORMIER wrote:
> grammar unicodeEssai;
>
> ID : ID_START_LETTER ( ID_LETTER )*
> ;
> ID_START_LETTER
> : '$'
> | '_'
> | 'a'..'z'
> | '\u0080'..'\ufffe'
> ;
> ID_LETTER
> : ID_START_LETTER
> | '0'..'9'
> ;
presumably you want to get only ID tokens in your parser, right?
ANTLR tries to match either ID, ID_START_LETTER, or ID_LETTER.
For input like
$0
there are two possibilities:
1) ID ID_LETTER
2) ID_START_LETTER ID_LETTER
Try this (which is probably what you want, anyway):
grammar unicodeEssai;
ID : ID_START_LETTER ( ID_LETTER )*
;
fragment
ID_START_LETTER
: '$'
| '_'
| 'a'..'z'
| '\u0080'..'\ufffe'
;
fragment
ID_LETTER
: ID_START_LETTER
| '0'..'9'
;
HTH,
-k
P.S.: Also see the wiki's Five Minute Introduction for an explanation!
<http://www.antlr.org/wiki/display/ANTLR3/Five+minute+introduction+to
+ANTLR+3>
--
Kay Röpke
http://classdump.org/
More information about the antlr-interest
mailing list