Jim,

Indeed, I want to use the custom pointer defined in ANTLR3_COMMON_TOKEN_struct. 
I have done this:

@init 
{
    double* pCustom = ANTLR3_MALLOC(sizeof(double));
    *pCustom = 0;
    CUSTOM = (ANTLR3_UINT32)pCustom;
}

My problem is that I have not found any way to set the freeCustom pointer (that 
is the pointer to a function that knows how to free the custom structure when 
the token is destroyed). I have probably missed something but the only way I 
have found to set this freeCustom pointer was to override the emit function. Is 
there another way to do it?

Thanks,
Yann


> Message du 15/01/10 à 18h50
> De : "Jim Idle" <[email protected]>
> A : "[email protected]" <[email protected]>
> Copie à : 
> Objet : Re: [antlr-interest] Overriding the emit function to use custom       
> tokens
> 
> No, you have to override nextToken too it calls emit directly for performance 
> reasons. 
> 
> However, no one really needs to do this. There is a user defined pointer 
> built in to every token and a function pointer that is called when the token 
> is released (if it is not NULL). So you can just add your custom token stuff 
> there and rely on the default runtime.
> 
> Jim
> 
> > -----Original Message-----
> > From: [email protected] [mailto:antlr-interest-
> > [email protected]] On Behalf Of [email protected]
> > Sent: Friday, January 15, 2010 5:53 AM
> > To: [email protected]
> > Subject: [antlr-interest] Overriding the emit function to use custom
> > tokens
> > 
> > Hello,
> > 
> > I wanted to create a custom token object, so I have seen in the FAQ
> > that I had to "override" the lexer emit function. So I did that this
> > way:
> > 
> > ...
> >         pLexer = antlrLexerNew(pInput);
> >         pLexer->pLexer->emit = customEmit;
> > ...
> > 
> > but it was not working.
> > 
> > The customEmit function was never called. So I have debugged and I
> > think there is a bug in antlr3lexer.c. In the nextTokenStr function,
> > shouldn't "emit(lexer)" be replaced by "lexer->emit(lexer);"? What do
> > you think?
> > 
> > Thanks,
> > Yann
> > 
> > ____________________________________________________
> > 
> > Vous n’avez pas encore adressé vos voeux ? Retrouvez nos cartes sur
> > http://carte-de-voeux.voila.fr
> > 
> > 
> > ____________________________________________________
> > 
> > Vous n’avez pas encore adressé vos voeux ? Retrouvez nos cartes sur
> > http://carte-de-voeux.voila.fr
> > 
> > 
> > 
> > 
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> > email-address
> 
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 

____________________________________________________

Vous n’avez pas encore adressé vos voeux ? Retrouvez nos cartes sur 
http://carte-de-voeux.voila.fr 




List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.


Reply via email to