English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
ocamlyacc/lex reentrancy
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-12-30 (18:46)
From: Francois Rouaix <frouaix@l...>
Subject: Re: ocamlyacc/lex reentrancy
I don't use ocamlyacc,  but I do have lots of ocamllex lexers that need
to be reentrant. I don't remember if I've  posted that trick to the list
already, but this is what you can do:

In your opening section of the lexer:

type t = <something to store the data>

let create_data () = ....    (* unit -> t *)


and then for all rules, use

rule somerule = parse
 | somepattern { (fun lexdata -> action) }

And, when invoking a lexer function or entry point,  you need to pass the
additionnal argument, a in
  somerule lexbuf lexdata