Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] On ocamlyacc and ocamllex
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian RINDERKNECHT <rinderkn@h...>
Subject: Re: [Caml-list] On ocamlyacc and ocamllex
Hi,

Vesa Karvonen wrote:
> Currently the generated lexer is dependent on the parser, because the
> parser generates the token type. This means that each time the grammar is
> modified, but not the token definitions, the lexer is recompiled. 

Sometimes ago, I wrote a software handling more than six lexers and
parsers, and hence maintenance was complex. So I decided to enhance
ocamllex with the following facilities through the command-line: 

  (1) It can produce a functorized lexer whose argument defines the
      tokens. You need to use to same %token clauses as in ocamlyacc.
      This way different parsers can share the same lexer (the only
      constraint is that the %token clause in the ocamllyacc-generated
      parsers must be given in the same order).

  (2) It is possible to specify a signature to be shared among
      different generated lexers.

  (3) If you don't want a functorized lexer to be produced, you can
      nevertheless specify the module defining the tokens (not
      necessarily the ocamlyacc-generated parser). This allows you to
      produce from the same ocamllex specification either a
      functorized lexer or a non-functorized lexer.

  (3bis) You can even allow the functorized lexer to import a module
      whose signature is given by a new clause: %import.

Note also that:

  (4) By default, the behaviour is exactly the same as for the
      distributed ocamllex.

  (5) I integrated the patch of Christian Lindig, allowing you to give
      arguments to your lexing rules (e.g. rule skip_line (loc) =
      parse ...). In think this will help you to write functionnal
      lexers in a readable way.

  (6) I documented the options in an enhanced version of the man page.

  (7) It is up-to-date with respect to the latest distribution of
      ocamllex. 

If you are interested, please send me an e-mail.

Best regards,

-- 

Christian

------------------------------------------------------------------------
Christian Rinderknecht                     Phone  +82 42 866 6147
Network Architecture Laboratory            Fax    +82 42 866 6154
Information and Communications University  WWW    http://nalab.icu.ac.kr
58-4 Hwaam-dong, Yuseong-gu, Daejeon,      e-mail rinderkn@icu.ac.kr
305-752, Korea
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr