From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA10523; Wed, 10 Apr 2002 10:10:58 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA12601 for ; Wed, 10 Apr 2002 10:10:57 +0200 (MET DST) Received: from ritchie.cas.McMaster.CA (ritchie.cas.McMaster.CA [130.113.68.10]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3A89nj11624 for ; Wed, 10 Apr 2002 10:09:50 +0200 (MET DST) Received: from demokrit.cas.mcmaster.ca (demokrit.cas.McMaster.CA [130.113.68.194]) by ritchie.cas.McMaster.CA (8.11.6+Sun/8.11.6) with ESMTP id g39IAu201454; Tue, 9 Apr 2002 14:10:56 -0400 (EDT) Received: (from kahl@localhost) by demokrit.cas.mcmaster.ca (8.11.6/8.11.6/SuSE Linux 0.5) id g39I9TV03521; Tue, 9 Apr 2002 14:09:29 -0400 Date: Tue, 9 Apr 2002 14:09:29 -0400 Message-Id: <200204091809.g39I9TV03521@demokrit.cas.mcmaster.ca> X-Authentication-Warning: demokrit.cas.mcmaster.ca: kahl set sender to kahl@cas.mcmaster.ca using -f From: Wolfram Kahl To: caml-list@inria.fr CC: rtarpine@hotmail.com In-reply-to: (rtarpine@hotmail.com) Subject: Re: [Caml-list] Cannot find Stream Parser Documentation References: Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk To my questions about streams and camlp4, I received two answers so far: The first one from Ryan Tarpine unintentionally didn't make it to the list: > > >From: Wolfram Kahl > >To: caml-list@inria.fr > >Subject: [Caml-list] Cannot find Stream Parser Documentation > >Date: Fri, 5 Apr 2002 13:58:18 -0500 > > > >... > > > >The documentation for stream parsers that had been in the > >``Language extensions'' chapter of the OCaml manual > >seems to have disappeared, too. > >I looked for it in the camlp4 directory, > >but that directory doesn't even contain a README. > > > >In the OCaml distribution, camlp4 seems to come with no documentation > >besides the manpage! > >(And on the camlp4 web pages, I couldn't find anything related > > to the implementation of streams.) > > I found the most information on stream parsers to be in camlp4's tutorial > section, not the reference manual like I expected. See > for the best info I > stumbled across. It seems that '??' is the correct syntax, and your code > works if you take out the 'when' clause, so maybe this is a bug? > > >A related issue: Among about 50 modules, only one uses stream parsers. > >But > > > > ocamldep -pp camlp4o *.mli *.ml > .depend > > > >takes much longer than without camlp4. > >How can I tell ocamldep to use camlp4 only for this file? > > > >... > > I recommend using Mr. Mottl's OCamlMakefile to manage your project. See > > for info. With OCamlMakefile you just place the comment (*pp camlp4o *) at > the top of any files that need to be preprocessed, and it takes care of the > dirty work! > > HTH, > > Ryan Tarpine, rtarpine@hotmail.com > "To err is human, to compute divine. Trust your computer but not its > programmer." > - Morris Kingston > In the second, Jean-Christophe Filliatre provides a practical pattern for use in hand-made makefiles: > > Regarding dependencies, there are several solutions. As far as I'm > concerned, I chose to name my camlp4 files .ml4 and to produce the .ml > file before computing the dependencies, like this: > > ====================================================================== > foo.ml: foo.ml4 > camlp4o pr_o.cmo -impl $< > $@ > > depend: foo.ml > ocamldep *.ml *.mli > .depend > ====================================================================== > > Of course, I do not produce the .ml file for compiling; I use ocamlc > -pp: > > ====================================================================== > foo.cmo: foo.ml4 > ocamlc -c -pp "camlp4o -impl" -impl $< > > ====================================================================== This solves my ocamldep problem. However, my real problem is not solved yet: The stream language as currently supported by camlp4 apparently does not contain the full stream language of OCaml 3.02 (and many, many previous versions), and I cannot find any document that explains the differences. (In addition, all the OCaml sites at INRIA seem to be down since at least yesterday ...) So I did a few experiments with camlp4 stream translation: My original code (this worked for years!): Input 1: ------------------------------- let pc0 c = parser n [< ' x when x == c ?? (string_of_int n ^ ": pc '" ^ String.make 1 c ^ "'") >] -> ();; ------------------------------- Message: ------------------------------- File "streamTest.ml4", line 4, characters 8-10: Parse error: '>]' expected after [stream_patt] (in [parser_case]) ------------------------------- The error points to `??'. Since Ryan Tarpine points out that the ``when'' might be the problem, but I need the condition, I try to factorise: Input 2: ------------------------------- let pc0 c = parser n [< ' x when (x == c) >] -> ();; let pc c = parser n [< _ = pc0 c ?? (string_of_int n ^ ": pc '" ^ String.make 1 c ^ "'") >] -> ();; ------------------------------- Message: ------------------------------- File "streamTest.ml4", line 7, characters 8-10: Parse error: '>]' expected after [stream_patt] (in [parser_case]) ------------------------------- The error points to `??', again. This is particularly interesting given that the following works (only difference: two invocations of pc0 before `??'): Input 3: ------------------------------- let pc0 c = parser n [< ' x when (x == c) >] -> ();; let pc c = parser n [< _ = pc0 c; _ = pc0 c ?? (string_of_int n ^ ": pc '" ^ String.make 1 c ^ "'") >] -> ();; ------------------------------- Output: ------------------------------- let pc0 c (strm__ : _ Stream.t) = let n = Stream.count strm__ in match Stream.peek strm__ with Some x when x == c -> Stream.junk strm__; () | _ -> raise Stream.Failure ;; let pc c (strm__ : _ Stream.t) = let n = Stream.count strm__ in let _ = pc0 c strm__ in let _ = try pc0 c strm__ with Stream.Failure -> raise (Stream.Error (string_of_int n ^ ": pc '" ^ String.make 1 c ^ "'")) in () ;; ------------------------------- Against my expectations, only the last invocation of pc0 is inside the try ... catch. (Parentheses around the two invocations of pc0 are not accepted.) I'm puzzled... Should I rather recode all my 247 Stream parsers manually? Wolfram ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners