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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL 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 E7F78BC6B for ; Thu, 9 Aug 2007 20:31:39 +0200 (CEST) Received: from ausone.inria.fr (peray.inria.fr [128.93.8.98]) by discorde.inria.fr (8.13.6/8.13.6) with SMTP id l79IVbBC009846; Thu, 9 Aug 2007 20:31:37 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Thu, _d Aug 2007 20:31:15 +0200 From: "Nicolas Pouillard" Cc: "O'Caml Mailing List" Subject: RE: [Caml-list] Equivalent of Quotation.ExStr in new camlp4? To: Harrison John R References: <509223F0BF55E74FA1247D17207E7A0C01B12606@orsmsx419.amr.corp.intel.com> In-Reply-To: <509223F0BF55E74FA1247D17207E7A0C01B12606@orsmsx419.amr.corp.intel.com> Date: Thu, 09 Aug 2007 20:31:15 +0200 Message-Id: <1186684229-sup-4122@ert.local> User-Agent: Sup/0.1.$Revision:$ Content-Disposition: inline Content-Type: text/plain; charset=utf-8 X-j-chkmail-Score: MSGID : 46BB5D89.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46BB5D89.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp: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 expr:01 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: > > | $ 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] > 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 = > Camlp4OCamlParser.Make > (Camlp4OCamlRevisedParser.Make > (Camlp4.OCamlInitSyntax.Make(Ast)(Gram)(Quotation)));; > > let quotexpander str = > "[1; 2; 3]" (* ... do some real code on str *) > > let patt_quotexpander loc _loc_name_opt str = > Gram.parse_string Caml.patt loc (quotexpander str) > > let expr_quotexpander loc _loc_name_opt str = > Gram.parse_string Caml.expr loc (quotexpander str) > > let str_item_quotexpander loc loc_name_opt str = > <:str_item@loc< $exp: expr_quotexpander loc loc_name_opt str$ >> > > let () = > 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 > > -- > Nicolas Pouillard -- Nicolas Pouillard aka Ertai