On 11 Feb 2008, at 09:17, Aaron Jackson wrote:

I would like to declare some variables that are local to yyparse. I am building a linked list of structures, and I need to make sure I have values for all the structure members before I add a new node to the list. Since I wrote the parser to be a pure parser, global variables, are not an option. Something like %initial-action {int x; int y; int z;} doesn't work, since the initial action code is enclosed in braces and the variables x,y,z,etc. do not exist outside the braces.

If that happens, it is probably a bug.

If I use %parse-param{variables_t variables;}, where variables_t is a structure containing x,y,z, I get what I want, but since I don't need x,y,z after yyparse returns, this seems like an inefficient way to do things. Is there a better way to do this?

There is a command %define or something that lets you defining a M4 macor that can be put into the skeleton file.

There must be a "standard" way this is done---temporarily saving all the previously parsed values until all the required values are available.

Not really: the origin is in impure parsers for rather standard situations.

  Hans Aberg




_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to