[antlr-interest] Simple question

Hill, Robert rhill03 at eds.com
Tue Jul 25 07:29:07 PDT 2006


You need to get the Lexer to return 1 token containing all your
characters (probably best calling it a "String" or "CharacterLiteral"
perhaps ;) ) instead of the lexer returning 1 token per char and
building a tree of those single character tokens.

try

>chars	:	CHAR	;
>option buildAST is set to true;

>CHAR	:   ('a'..'z' | 'A'..'Z')+;

Cheers,
Rob



--
Rob Hill
EDS - Hallamshire Business Park
F1E/045
Sheffield	
T:	+44 (0) 114 291 1928
M:	+44 (0) 791 732 1227
E:	rhill03 at eds.com

 

>-----Original Message-----
>From: antlr-interest-bounces at antlr.org 
>[mailto:antlr-interest-bounces at antlr.org] On Behalf Of dotnet fr
>Sent: 25 July 2006 13:10
>To: antlr-interest at antlr.org
>Subject: [antlr-interest] Simple question
>
>Hi Everyone,
>
>I've got a simple question :
>
>-in the parser I have :
>chars	:	(CHAR)+	;
>option buildAST is set to true;
>
>-in the lexer I have :
>CHAR	:   ('a'..'z') | ('A'..'Z')    ;
>
>When I print the ast, my chars is not a token but a letter 
>(the first) with a lot of siblings. How to get the chars like a Token ?
>
>Thank you in advance
>
>--
>dotnet
>


More information about the antlr-interest mailing list