[antlr-interest] How to translate this V2 Lexer rule to V3 Lexer rule?

Jim Idle jimi at temporal-wave.com
Wed Dec 3 07:25:54 PST 2008


On Wed, 2008-12-03 at 14:57 +0800, chain one wrote:

> Sorry for spaming
> 
> 
> 
> I noticed that only to remove the '$' in front of getText and
> setType() would work.
> What a stupid question! : )
> 


Actually, you should not do that in V3 lexers :-) You hsoudl use:

System.out.println($text);

and

$type = MY_INT_TYPE;

Jim

> 2008/12/3 chain one <chainone at gmail.com>
> 
>         The V2 Lexer rule is:
>         
>         
>         
>         IDENT
>         
>         
>         : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
>         { 
>         if (!parser.isFirst) $setType(globalSearchId($getText()));
>         }
>         ;
>         
>         
>         
>         
>         I searched in the ANTLR V3 book but failed to find the way to
>         get the Lexer rule's Text and Type directly from
>         its alternatives.
>         
>         
>         Anyone who knows , could you please drop me an email?
>         Thanks very much!
>         Best Regards,
>         Chainone
>         
>         
> 
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081203/491e7257/attachment.html 


More information about the antlr-interest mailing list