Re: ocamlyacc/lex reentrancy

From: Francois Rouaix (frouaix@liquidmarket.com)
Date: Thu Dec 30 1999 - 19:30:39 MET


Message-Id: <199912301830.KAA12278@fiji01.liquidmarket.com>
From: Francois Rouaix <frouaix@liquidmarket.com>
To: skaller <skaller@maxtal.com.au>
Subject: Re: ocamlyacc/lex reentrancy
Date: Thu, 30 Dec 1999 10:30:39 -0800

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

--f



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