From: Francois Pottier <Francois.Pottier@inria.fr>
To: Joel Reymont <joelr1@gmail.com>
Cc: menhir-list@yquem.inria.fr, Caml List <caml-list@inria.fr>
Subject: Re: [Menhir-list] Passing a symbol table to the parser
Date: Fri, 27 Apr 2007 10:13:28 +0200 [thread overview]
Message-ID: <20070427081328.GC29647@yquem.inria.fr> (raw)
In-Reply-To: <8579A443-8337-43CC-93E6-FDAE58706F32@gmail.com>
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/
prev parent reply other threads:[~2007-04-27 8:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-26 8:48 Joel Reymont
2007-04-27 8:13 ` Francois Pottier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070427081328.GC29647@yquem.inria.fr \
--to=francois.pottier@inria.fr \
--cc=caml-list@inria.fr \
--cc=joelr1@gmail.com \
--cc=menhir-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox