[Gllug] Bison question
rich at annexia.org
rich at annexia.org
Wed Dec 4 17:04:40 UTC 2002
I don't know if anyone knows anything about bison/yacc, but here goes ...
I have a bison rule which looks like this:
%union {
char *filename;
...
}
%type <filename> filename
%%
filename
: STRING
{
$$ = strdup (mp_string);
}
'(' props ')'
{
/* Make sure the file exists. */
file_add ($$);
/* Add the properties to the file. */
file_set_props ($$, $<props>3);
}
;
The idea is that the first clause saves mp_string (which is likely
to get overwritten by parsing the 'props' non-terminal). Then in the
second clause we call file_add with the saved filename. But tracing
this in gdb, I find that by the time we get to file_add, $$ is equal
to NULL (not my saved char *).
Any ideas why this is?
Do I need to use a global variable for this sort of thing?
Rich.
--
Richard Jones, Red Hat Inc. (London, UK) http://www.redhat.com/software/ccm
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list