[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2007-04-27 (08:13) |
From: | Francois Pottier <Francois.Pottier@i...> |
Subject: | Re: [Menhir-list] Passing a symbol table to the parser |
Hello, 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.Pottier@inria.fr http://cristal.inria.fr/~fpottier/