From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id B5B3FBC6B for ; Fri, 27 Apr 2007 10:13:29 +0200 (CEST) Received: from yquem.inria.fr (yquem.inria.fr [128.93.8.37]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3R8DSTo015030; Fri, 27 Apr 2007 10:13:28 +0200 Received: by yquem.inria.fr (Postfix, from userid 18965) id B1AA8BC6B; Fri, 27 Apr 2007 10:13:28 +0200 (CEST) Date: Fri, 27 Apr 2007 10:13:28 +0200 From: Francois Pottier To: Joel Reymont Cc: menhir-list@yquem.inria.fr, Caml List Subject: Re: [Menhir-list] Passing a symbol table to the parser Message-ID: <20070427081328.GC29647@yquem.inria.fr> Reply-To: Francois.Pottier@inria.fr References: <8579A443-8337-43CC-93E6-FDAE58706F32@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8579A443-8337-43CC-93E6-FDAE58706F32@gmail.com> User-Agent: Mutt/1.5.9i X-Miltered: at discorde with ID 4631B0A8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; parser:01 0100,:01 parser:01 mutable:01 hash:01 mutable:01 functor:01 sig:01 val:01 val:01 26,:98 wrote:01 cristal:01 pottier:01 pottier:01 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 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/