From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id VAA26146 for caml-redistribution; Tue, 5 Oct 1999 21:53:38 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA19302 for ; Tue, 5 Oct 1999 21:36:08 +0200 (MET DST) Received: from beach.frankfurt.netsurf.de ([194.64.181.2]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id VAA17093 for ; Tue, 5 Oct 1999 21:36:06 +0200 (MET DST) Received: from ice.darmstadt.netsurf.de (board-108.darmstadt.netsurf.de [194.163.86.236]) by beach.frankfurt.netsurf.de (8.8.5/8.8.5) with ESMTP id VAA14698; Tue, 5 Oct 1999 21:36:00 +0200 (MET DST) Received: from localhost (localhost [[UNIX: localhost]]) by ice.darmstadt.netsurf.de (8.9.3/8.9.3) id VAA17421; Tue, 5 Oct 1999 21:35:51 +0200 From: Gerd Stolpmann Reply-To: Gerd.Stolpmann@darmstadt.netsurf.de Organization: privat To: skaller Subject: Re: Can someone explain? Date: Tue, 5 Oct 1999 21:35:34 +0200 X-Mailer: KMail [version 1.0.21] Content-Type: text/plain References: <37F930D0.6547CE0F@maxtal.com.au> MIME-Version: 1.0 Message-Id: <99100521343800.17263@ice> Content-Transfer-Encoding: 8bit Cc: caml-list@inria.fr Sender: weis On Tue, 05 Oct 1999, John Skaller wrote: > The other thing I would beg for is to fix the parser >and lexer to be re-entrant [purely functional]. At present, state >information >must be kept in global store :-( > > It would also be useful if the parser could support nested >parser calls as the lexer can: this is possible with the lexer, >because the lexbuf is always in a state to read the next lexeme, >however it is not possible with the parser because it may have read >a token ahead of the production being reduced. I have recently posted a solution for this problem by turning the generated parser into a class; side-effects still exist but are limited to the object representing the parser. You can simply create several instances of the same parser, and nested parser calls are possible if the sub-parser resides in a different object than the calling parser. The solution requires a complicated Makefile, and I again suggest to support an object-oriented parser generator in one of the next caml releases. You find a description of the idea here: http://pauillac.inria.fr/caml/caml-list/1575.html A working application is my XML parser, look at the files markup_yacc.mly and Makefile.code in http://people.darmstadt.netsurf.de/Gerd.Stolpmann/ocaml/markup-0.2.tar.gz As any real application, this parser is much more complicated than necessary to demonstrate the principle... Gerd -- ---------------------------------------------------------------------------- Gerd Stolpmann Telefon: +49 6151 997705 (privat) Viktoriastr. 100 64293 Darmstadt EMail: Gerd.Stolpmann@darmstadt.netsurf.de (privat) Germany ----------------------------------------------------------------------------