Re: lexer, parser

From: Christian Lindig (lindig@ips.cs.tu-bs.de)
Date: Mon Jun 14 1999 - 09:15:43 MET DST


Date: Mon, 14 Jun 1999 09:15:43 +0200
From: Christian Lindig <lindig@ips.cs.tu-bs.de>
To: John Skaller <skaller@maxtal.com.au>,
Subject: Re: lexer, parser
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

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



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:23 MET