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 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8267FBC6C for ; Wed, 2 May 2007 20:30:30 +0200 (CEST) Received: from yquem.inria.fr (yquem.inria.fr [128.93.8.37]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l42IUKi0016006; Wed, 2 May 2007 20:30:20 +0200 Received: by yquem.inria.fr (Postfix, from userid 18965) id 60B8BBC69; Wed, 2 May 2007 20:30:20 +0200 (CEST) Date: Wed, 2 May 2007 20:30:20 +0200 From: Francois Pottier To: skaller Cc: Caml List , menhir-list@yquem.inria.fr Subject: Re: [Caml-list] Re: [Menhir-list] There's an elephant in the room: Solution to sharing a symbol table Message-ID: <20070502183020.GA17473@yquem.inria.fr> Reply-To: Francois.Pottier@inria.fr References: <1EE80473-541D-478D-97F8-06A1B5F65F79@gmail.com> <20070502054411.GB726@yquem.inria.fr> <8C011A98-CE76-4A83-B24C-BA37B66DF15D@gmail.com> <1178096690.13660.80.camel@rosella.wigram> <20070502115635.GA21560@yquem.inria.fr> <1178122046.6486.31.camel@rosella.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1178122046.6486.31.camel@rosella.wigram> User-Agent: Mutt/1.5.9i X-Miltered: at concorde with ID 4638D8BC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; trivial:01 bool:01 parser:01 parsing:01 parser:01 abstracted:01 functors:01 parses:01 stack:01 elephant:98 invoke:01 wrote:01 cristal:01 recursively:01 recursively:01 Hi, On Thu, May 03, 2007 at 02:07:26AM +1000, skaller wrote: > State must be maintained in function arguments. This is a trivial example, but: let x = ref 0 let f () : bool = incr x; x / 2 = 0 Here, f exploits an internal state, even though it is not explicitly parameterized over a piece of state. Similarly, a parser can have internal state, even if the parsing functions are not explicitly parameterized over a piece of state. It is sufficient for the entire parser either to refer to a global variable or to abstracted over a piece of state (which functors allow). > When the parser sees the include statement it parses the > file 'filename'. The parse of the included file, in Felix, > is independent of the surrounding code. The parser is > called recursively and the resulting AST is returned > from the user action. > > There is no way to do this without passing a state variable > on the stack. I don't see why this is so. In fact, nothing in your example seems to require any kind of state -- you only need the parser to be able to recursively invoke itself. Or am I missing something? -- François Pottier Francois.Pottier@inria.fr http://cristal.inria.fr/~fpottier/