[antlr-interest] IDENTifier rule not working for some tokens

brainstorm braincode at gmail.com
Tue Oct 21 02:28:35 PDT 2008


Hello,

Newbie question :)

I'm developing my grammar and I get to a point where a simple token
like "bb" is not recognized as a regular identifier. I'm using the
following IDENT definition, like many grammars in antlr.org's
Downloads section:

IDENT	:	'a'..'z' ('a'..'z'|'A'..'Z'|'0'..'9')* ;
INTCONST:	('0'..'9')+ ;

I used to work with antlr v2 and C++, the definition for this token on
the same grammar was straightforward and worked well:

#token IDENT        "[a-zA-Z][a-zA-Z0-9]*"
#token INTCONST     "[0-9]+"

I'm attaching:

1) The grammar
2) jp2: For instance, the IDENT "p12" is correctly recognized an
placed on correct child on the parse tree.
3) jp4: The ident "bb" is splitted in the parse tree as "b" "b" on
different nodes, not detected as a whole identifier, why ? What am I
doing wrong ? :/

Thanks in advance !
Roman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CL.g
Type: application/octet-stream
Size: 2836 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081021/970df9c3/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jp4
Type: application/octet-stream
Size: 821 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081021/970df9c3/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jp2
Type: application/octet-stream
Size: 602 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081021/970df9c3/attachment-0002.obj 


More information about the antlr-interest mailing list