[antlr-interest] C target help

Jim Idle jimi at temporal-wave.com
Tue Dec 16 17:48:01 PST 2008


On Tue, 16 Dec 2008 16:27:38 -0800, Ilyevsky, Leonid (Equity Trading) <Leonid_Ilyevsky at ml.com> wrote:

>Jim,
>
> I found another issue. I am just following the example, parsing the
> string, getting the tree and trying to print it out. The code is below.
>

I think that you should first check your own memory usage with valgrind to be honest. The other possibility is that you are trying to use text from tokens that do not have anything in them, such as imaginary tokens.

Remove any action code and make sure your lexer is not trying to set the token text. The get the feel of this with a very simple grammar.

Then see if you can print the tree. Imaginary tokens with incorrect text are my bet though. Might be a left over from my change from calloc to malloc, or the new way that imaginary tokens store their text in 3.1.1. Will try to look at the possibilities tomorrow. 


Jim

> The program dies at the line
>
> cout << "Tree: " << ast.tree->toStringTree(ast.tree)->chars << endl;
>
> As I put some debugging in the antlr core code, I see that the problem
> is corrupted token object.
> Here is my test output:
>
> -----------------------------------------------
> QUERY: select from TestCache where X = 123
> Init parser
> About to parse
> Parsing done
> Parser succeeded
> src/antlr3basetree.c:255
> src/antlr3basetree.c:269
> src/antlr3commontree.c:423
> src/antlr3commontree.c:434
> src/antlr3commontoken.c:346
> src/antlr3commontoken.c:367
> Token: Tz Start: -1612541768 End: -1612541760
> Process died unexpectedly .....
> -----------------------------------------------
>
> I am not sure what should be the start and stop number in the token, but
> those huge negative numbers do not look right.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081216/d203148f/attachment.html 


More information about the antlr-interest mailing list