* Passing a symbol table to the parser
@ 2007-04-26 8:48 Joel Reymont
2007-04-27 8:13 ` [Menhir-list] " Francois Pottier
0 siblings, 1 reply; 2+ messages in thread
From: Joel Reymont @ 2007-04-26 8:48 UTC (permalink / raw)
To: menhir-list; +Cc: Caml List
Folks,
How would I pass a symbol table to a Menhir parser so that it's
available in my rules?
Thanks, Joel
--
http://wagerlabs.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Menhir-list] Passing a symbol table to the parser
2007-04-26 8:48 Passing a symbol table to the parser Joel Reymont
@ 2007-04-27 8:13 ` Francois Pottier
0 siblings, 0 replies; 2+ messages in thread
From: Francois Pottier @ 2007-04-27 8:13 UTC (permalink / raw)
To: Joel Reymont; +Cc: menhir-list, Caml List
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-04-27 8:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-26 8:48 Passing a symbol table to the parser Joel Reymont
2007-04-27 8:13 ` [Menhir-list] " Francois Pottier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox