From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E9767BC69 for ; Wed, 22 Aug 2007 20:04:33 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7MGLoWG006406 for ; Wed, 22 Aug 2007 18:21:51 +0200 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 22 Aug 2007 09:21:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.19,295,1183359600"; d="scan'208";a="286459879" Received: from orsmsx334.jf.intel.com ([10.22.226.45]) by fmsmga001.fm.intel.com with ESMTP; 22 Aug 2007 09:21:49 -0700 Received: from orsmsx419.amr.corp.intel.com ([10.22.226.88]) by orsmsx334.jf.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 22 Aug 2007 09:21:49 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Equivalent of Quotation.ExStr in new camlp4? Date: Wed, 22 Aug 2007 09:21:48 -0700 Message-ID: <509223F0BF55E74FA1247D17207E7A0C01CA3998@orsmsx419.amr.corp.intel.com> In-Reply-To: <1186684229-sup-4122@ert.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [Caml-list] Equivalent of Quotation.ExStr in new camlp4? Thread-Index: Acfas4duYwVg+/GAS4islSUL6H3x9gKJLLFg References: <509223F0BF55E74FA1247D17207E7A0C01B12606@orsmsx419.amr.corp.intel.com> <1186684229-sup-4122@ert.local> From: "Harrison, John R" To: "Nicolas Pouillard" Cc: "O'Caml Mailing List" X-OriginalArrivalTime: 22 Aug 2007 16:21:49.0329 (UTC) FILETIME=[8AA20010:01C7E4D8] X-Miltered: at concorde with ID 46CC629E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 o'caml:01 parsers:01 ocamlc:01 -pp:01 toplevel:01 parser:01 expander:01 concretely:01 expander:01 instanciate:01 ocaml:01 parser:01 expr:01 Thanks; unfortunately in the gap between your two messages I really needed to get my code running, so I just took the path of least resistance and switched to camlp5. But I'll re-examine this in the future when I have more time. John. -----Original Message----- From: Nicolas Pouillard [mailto:nicolas.pouillard@gmail.com]=20 Sent: Thursday, August 09, 2007 11:31 AM To: Harrison, John R Cc: O'Caml Mailing List Subject: RE: [Caml-list] Equivalent of Quotation.ExStr in new camlp4? Sorry, I used ocamlbuild to use this example and show it without ;( I forgot -I +camlp4/Camlp4Parsers Excerpts from Harrison, John R's message of Thu Jul 26 18:49:19 +0200 2007: > Trying your example in 3.10.0, I get the following: >=20 > | $ ocamlc -pp camlp4of -I +camlp4 -c ex_str.ml > | File "ex_str.ml", line 2, characters 2-24: > | Unbound module Camlp4OCamlParser.Make >=20 > I get a similar error in the toplevel even after #load "camlp4o.cma". > Do I need to load and/or open something else? >=20 > John. >=20 > -----Original Message----- > From: Nicolas Pouillard [mailto:nicolas.pouillard@gmail.com]=20 > Sent: Thursday, July 26, 2007 1:44 AM > To: Harrison, John R > Cc: caml-list@yquem.inria.fr > Subject: Re: [Caml-list] Equivalent of Quotation.ExStr in new camlp4? >=20 > On 7/25/07, Harrison, John R wrote: > > | No ExStr is no more supported. But you can do it your self by > calling > > | the parser on your string if you really don't want switch to an AST > > | based quotation expander. > > > > OK, that's fine. But how do I do that? Concretely, this is what I had > > before, so what should I have now? > > > > Quotation.add "" (Quotation.ExStr (fun x -> quotexpander));; > > > > I don't mind in principle writing an AST-producing expander, but at > the > > moment the priority is to get my code working in 3.10 with minimal > > expenditure of effort. > > >=20 > You can instanciate an OCaml parser that way: >=20 > $ cat ex_str.mlmodule Caml =3D > Camlp4OCamlParser.Make > (Camlp4OCamlRevisedParser.Make > (Camlp4.OCamlInitSyntax.Make(Ast)(Gram)(Quotation)));; >=20 > let quotexpander str =3D > "[1; 2; 3]" (* ... do some real code on str *) >=20 > let patt_quotexpander loc _loc_name_opt str =3D > Gram.parse_string Caml.patt loc (quotexpander str) >=20 > let expr_quotexpander loc _loc_name_opt str =3D > Gram.parse_string Caml.expr loc (quotexpander str) >=20 > let str_item_quotexpander loc loc_name_opt str =3D > <:str_item@loc< $exp: expr_quotexpander loc loc_name_opt str$ >> >=20 > let () =3D > Syntax.Quotation.add "" Syntax.Quotation.DynAst.expr_tag > expr_quotexpander; > Syntax.Quotation.add "" Syntax.Quotation.DynAst.str_item_tag > str_item_quotexpander; > Syntax.Quotation.add "" Syntax.Quotation.DynAst.patt_tag > patt_quotexpander >=20 > $ ocamlc -pp camlp4of -I +camlp4 -c ex_str.ml > $ camlp4o ./ex_str.cmo -str '<<>>;;' >=20 > HTH >=20 > --=20 > Nicolas Pouillard --=20 Nicolas Pouillard aka Ertai