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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 5DAFDBC6B for ; Thu, 26 Jul 2007 18:49:24 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6QGnLfn020214 for ; Thu, 26 Jul 2007 18:49:23 +0200 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 26 Jul 2007 09:49:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.16,584,1175497200"; d="scan'208";a="255154543" Received: from orsmsx334.jf.intel.com ([10.22.226.45]) by azsmga001.ch.intel.com with ESMTP; 26 Jul 2007 09:49:20 -0700 Received: from orsmsx419.amr.corp.intel.com ([10.22.226.88]) by orsmsx334.jf.intel.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 26 Jul 2007 09:49:20 -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: Thu, 26 Jul 2007 09:49:19 -0700 Message-ID: <509223F0BF55E74FA1247D17207E7A0C01B12606@orsmsx419.amr.corp.intel.com> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [Caml-list] Equivalent of Quotation.ExStr in new camlp4? Thread-Index: AcfPYR99bCAC3sH9RoCQaht14LlfgAAQ5vgg From: "Harrison, John R" To: "Nicolas Pouillard" Cc: X-OriginalArrivalTime: 26 Jul 2007 16:49:20.0402 (UTC) FILETIME=[E9987F20:01C7CFA4] X-Miltered: at discorde with ID 46A8D091.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 ocamlc:01 -pp:01 camlp:01 toplevel:01 parser:01 expander:01 concretely:01 expander:01 instanciate:01 ocaml:01 parser:01 expr:01 expr:01 syntax:01 Trying your example in 3.10.0, I get the following: | $ ocamlc -pp camlp4of -I +camlp4 -c ex_str.ml | File "ex_str.ml", line 2, characters 2-24: | Unbound module Camlp4OCamlParser.Make I get a similar error in the toplevel even after #load "camlp4o.cma". Do I need to load and/or open something else? John. -----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? 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. > You can instanciate an OCaml parser that way: $ cat ex_str.mlmodule Caml =3D Camlp4OCamlParser.Make (Camlp4OCamlRevisedParser.Make (Camlp4.OCamlInitSyntax.Make(Ast)(Gram)(Quotation)));; let quotexpander str =3D "[1; 2; 3]" (* ... do some real code on str *) let patt_quotexpander loc _loc_name_opt str =3D Gram.parse_string Caml.patt loc (quotexpander str) let expr_quotexpander loc _loc_name_opt str =3D Gram.parse_string Caml.expr loc (quotexpander str) let str_item_quotexpander loc loc_name_opt str =3D <:str_item@loc< $exp: expr_quotexpander loc loc_name_opt str$ >> 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 $ ocamlc -pp camlp4of -I +camlp4 -c ex_str.ml $ camlp4o ./ex_str.cmo -str '<<>>;;' HTH --=20 Nicolas Pouillard