Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token text messed up in C target #107

Open
martinfschaefer opened this issue Apr 10, 2013 · 0 comments
Open

Token text messed up in C target #107

martinfschaefer opened this issue Apr 10, 2013 · 0 comments

Comments

@martinfschaefer
Copy link

With a parser rule like this:

foo: '(' bar ')' -> ^(T_BAR[$bar.text] bar);

The returned string in the BAR token is corrupted.
The reason is that the following code is generated in the parser:

root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR,
(pANTLR3_BASE_TREE)ADAPTOR->createTypeText(ADAPTOR, T_BAR,
(pANTLR3_UINT8)(STRSTREAM->toStringTT(STRSTREAM, bar90.start, bar90.stop))),
root_1));

The toStringTT() method returns a pANTLR3_STRING pointer.
But the createTypeText() method (and the createToken() method that it calls) expects a UTF-8 char string.
The pANTLR3_STRING is eventually cast to pANTLR3_UCHAR and the text state set to ANTLR3_TEXT_CHARP.
Reading the token text from the token results in gibberish.

Tested with both ANTLR 3.4 and 3.5.
Is there any workaround available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant