How would I pass a symbol table to a Menhir parser so that it's
available in my rules?
Thanks, Joel
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
On Thu, Apr 26, 2007 at 09:48:35AM +0100, Joel Reymont wrote:
> How would I pass a symbol table to a Menhir parser so that it's
> available in my rules?
The most basic solution is to make the symbol table mutable (e.g. make it a
hash table, or a mutable reference to a persistent data structure) and place
it in a global variable in some earlier module.
If, in addition, you need reentrancy and don't want your parser to depend on a
global variable, then you can move this global variable to a functor parameter,
using a %parameter declaration, like this:
%parameter <T : sig
type symbol
type info
val get: symbol -> info
val set: symbol -> info -> unit
end>
Then, your semantic actions can refer to T.get and T.set, and Menhir produces
a parser that is parameterized over T.
--
François Pottier
Francois...@inria.fr
http://cristal.inria.fr/~fpottier/