> Even though Bison is a bottom up parser, if I need to pass a variable's
> content top-down, what are the possible ways (except using global
> variable)?

One way is to use the optional parameter that you can pass to `yyparse'.
It is a `void*' that can point to an object of whatever type you like. 
You'll need to cast it to the correct type in each rule in which you want
to access the structure, unless you're just passing it further to a
function (which takes a `void*' argument, obviously).

You can use this object to store whatever information you like.  My parser
(for GNU 3DLDF) needs to be thread-safe, so global variables wouldn't be a
good idea.  There's a `Scanner_Type' object (this is the type pointed to
by my `void* parameter') for each instance of `yyparse', each of which is
in a separate thread.

It works great for me.  If you want to see lots of examples, you could
look in the files with the suffix `.w' here:
http://cvs.savannah.gnu.org/viewvc/3dldf/3dldf/Group/CWEB/

`grep' for `parameter' and/or `Scanner_Node' (a `typedef' for
`Scanner_Type*').

Laurence Finston



_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to