[antlr-interest] Problem with C target output on example C grammar
Kamil Burzynski
nopik at data.pl
Tue Apr 1 11:22:02 PDT 2008
Hello,
> To follow up on this, I did successfully download the .tgz of the
> examples from Fisheye by right clicking the tgz link and selecting
> "save as" from IE 7, but the .zip format seems to be corrupt.
Till now I was using http://www.antlr.org/download/examples-v3.1b1.tar.gz
Now I had downloaded from fisheye, to the same result. This is no
surprise, since in both cases external_declaration goes to
function_definition without going through declaration, and
function_definition in turn calls declarator and direct_declarator,
while they require declaration to be on stack...
In meantime I have also managed to play a little with C target and while
it is working, I am little worried, as for now I have found 2 problems.
a) I wanted to do some lex/yacc-type return values:
declaration returns[ MyType result ] : ....
translation_unit returns[ MyType result ] :
d=declaration declaration* { result = ....; }
C target does insert:
MyType d = NULL;
in CParser.c. Unfortunately, with C++ MyType is quite complex. In fact
it is smart pointer (taken from boost library) to my class. The problem
is that you cannot do = NULL on it. The proper operation is just:
MyType d;
since its constructor will do the right thing anyway.
b) In some cases, by adding 'innocent' code whole thing crashes. Namely
I only add:
scope MyScope
{
int foo;
}
to the working project based on C.g3pl (without using MyScope anywhere)
and program crashes in very nasty way. Gdb says, that stack is corrupt
(well, if I would do step-by-step analysis I would find it, probably),
and valgrind says, that 'impossible happened' and internal valgrind
error occurred ;) The problem is that I was not able to reproduce it on
original C.g3pl file from examples ;( I did not made any serious
modifications yet, though I changed compilation mode slightly (whole
parser is in .so now). Without this additional scope everything works
fine, I can add my rules, actions, etc. And it seems, that I am alone
here, since nobody will reproduce it.. ;(
--
Best regards from
Kamil Burzynski
More information about the antlr-interest
mailing list