[antlr-interest] proplem with tokens value (C target)
Marco Trudel
marco at mtsystems.ch
Mon Aug 31 01:38:14 PDT 2009
As far as I understood (respectively experienced), tokText is not always
set. You probably want to do this:
char* tok_text = (token->getText(token) != NULL) ?
token->getText(token)->chars : token->tokText.chars;
At least that's what I'm doing to get the same result as
token.toString() in Java.
Hope that helps
Marco
Юрушкин Михаил wrote:
> there is following problem. I have made simple grammar, generated c. file
>
> But when I try to get "tokens text", the error is occured. here is a
> code of getters:
>
> #define getTokenText(token) string((char*)token->tokText.chars)
> #define getTokenInteger(token) atoi((char*)token->tokText.chars)
>
> I think, that tokens aren't initialized correctly, but what I did wrong...
>
> --
>
> Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/
>
>
> ------------------------------------------------------------------------
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list