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 RAA16692 for caml-redistribution; Mon, 14 Jun 1999 17:46:14 +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 JAA04712 for ; Mon, 14 Jun 1999 09:15:53 +0200 (MET DST) Received: from infbssys.ips.cs.tu-bs.de (infbssys.ips.cs.tu-bs.de [134.169.32.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id JAA15054 for ; Mon, 14 Jun 1999 09:15:51 +0200 (MET DST) Received: from infbsstq.ips.cs.tu-bs.de (lindig@infbsstq.ips.cs.tu-bs.de [134.169.32.78]) by infbssys.ips.cs.tu-bs.de (8.9.1/8.9.1) with ESMTP id JAA09706; Mon, 14 Jun 1999 09:15:44 +0200 Date: Mon, 14 Jun 1999 09:15:43 +0200 From: Christian Lindig To: John Skaller , Jean-Marc EBER Cc: Caml Mailing List Subject: Re: lexer, parser Message-ID: <19990614091543.A21998@ips.cs.tu-bs.de> Mail-Followup-To: John Skaller , Jean-Marc EBER , Caml Mailing List References: <0580637621241002*/c=FR/admd=ATLAS/prmd=SG/o=INFI/s=EBER/g=JEAN-MARC/@MHS> <0579137620FCB001*/c=FR/admd=ATLAS/prmd=SG/o=INFI/s=EBER/g=JEAN-MARC/@MHS> <3.0.6.32.19990603215554.0097b100@triode.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.1i In-Reply-To: <3.0.6.32.19990603215554.0097b100@triode.net.au>; from John Skaller on Thu, Jun 03, 1999 at 09:55:54PM +1000 Sender: weis Quoting John Skaller (skaller@maxtal.com.au): > I need to maintain state, but the component also need > to be re-entrant. Quoting Jean-Marc EBER (Jean-Marc.Eber@socgen.com): > You should certainly be in contact with Christian Lindig, who has > done interesting work on OCamlLex. > > lindig@ips.cs.tu-bs.de > http://www.cs.tu-bs.de/softech/people/lindig/index.html Hi, Like Jean-Marc Eber pointed out have I suggested two extension for OCamlLex that makes maintaining state easier: http://www.cs.tu-bs.de/softech/people/lindig/software/lex-patch.html A patched version of OCamlLex allows for additional parameters to rules: rule scan x y = parse ... Parameters like x and y make it easier to accumulate results across many calls of the same or different rules in a lexer. They help to avoid global variables which make a scanner no longer re-entrant. Using the patched version of OCamlLex is fairly uncritical because only the generated code if different from the original version. Maintaining state across different invocations of a lexer requires some more effort: http://www.cs.tu-bs.de/softech/people/lindig/software/lexing.html I have proposed a new Lexing module with a new `lexbuf' type. The lexbuf type is used by scanners to maintain state but currently does not hold user provided state. The proposed module permits to store user state in lexbuf as well. Unfortunately is it not possible to simply exchange the new module for the old. The whole OCaml system must be recompiled with the new module. However, all old code compiles with the new system. I still would like to see both proposals added to the OCaml system since both are backward compatible at the source code level. -- Christian -- Christian Lindig Technische Universitaet Braunschweig, Germany http://www.cs.tu-bs.de/softech/people/lindig lindig@ips.cs.tu-bs.de phone:+49-531-391-3276