[antlr-interest] (no subject)

tom_meyer at comcast.net tom_meyer at comcast.net
Mon May 8 15:04:26 PDT 2006


Hello,
 
How are custom attributes of a custom lexer token supposed to be set?
 
My token factory is set up to create MyToken objects, with
RefMyToken being a reference to one of these.  MyToken is
derived from other classes which track the usual text, line,
and column information.  In some cases I want to set an
additional attribute on the token.  
 
How is this supposed to be done?  I have followed the
information on how to create my own extended token class,
but don't know of any information on how to use it and set
fields from the lexer.
 
Below is an example of how I tried to set 'my_attribute'.  I
get a crash when I hack the code this way because _token is
NULL.  I see the methods like $setText(x) and $setToken(x).
I don't want to use $setToken(x) because the token gets
constructed fine, I just want to set an additional
attribute on the token.
 
 
      PLUS  : "+"
               {
                  RefMyToken my_token = RefMyToken( _token );
 
                  my_token->my_attribute = 99;
               }
            ;
 
Thanks,
-Tom
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060508/a1dabc1c/attachment.html


More information about the antlr-interest mailing list