[antlr-interest] Why I have to use explicitly $setType()?

mzukowski at bco.com mzukowski at bco.com
Mon Feb 11 07:33:18 PST 2002


ALERT really should be a keyword and not a lexer rule.  FUNCNAME should have
the option testLiterals set to true.  You should not have to set types
explicitly as you have done below, by default they are the same type as the
rule.

Read the generated code, it's always the key to understanding antlr.

Monty

> -----Original Message-----
> From: ycmichelid [mailto:michel_cedric at hotmail.com]
> Sent: Monday, February 11, 2002 6:08 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Why I have to use explicitly $setType()?
> 
> 
> My problem (http://groups.yahoo.com/group/antlr-interest/message/5028)
> seems to be also a conflict between keyword and identifier.
> 
> I found a solution to make my tokens being recognized normally.
> I have to explicitly use the function $setType().
> 
> In my case , rules in my lexer become (rule to skip whitespace
> ignored):
> 
> ALERT: "Alert" {$setType(TestTokenTypes.ALERT);};
> OPENPAR : "(" {$setType(TestTokenTypes.OPENPAR);};
> FUNCNAME : ('A'..'Z')( 'a'..'z' | 'A'..'Z' | '0'..'9' | '_' )+
>            {$setType(TestTokenTypes.FUNCNAME);}
> ;
> 
> So, it works now.
> But why do i have to set the type of the tokens manually?
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 



 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list