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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 79FB0BB84 for ; Sun, 21 Sep 2008 20:05:39 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al0BAOcp1kjANzRdmmdsb2JhbACTHQEBAQEBBg0KBxGhCoFm X-IronPort-AV: E=Sophos;i="4.32,441,1217800800"; d="scan'208";a="17570279" Received: from mga11.intel.com ([192.55.52.93]) by mail1-smtp-roc.national.inria.fr with ESMTP; 21 Sep 2008 20:05:38 +0200 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 21 Sep 2008 11:02:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.32,441,1217833200"; d="scan'208";a="618741852" Received: from unknown (HELO azsmsx001.amr.corp.intel.com) ([10.2.167.98]) by fmsmga001.fm.intel.com with ESMTP; 21 Sep 2008 11:06:32 -0700 Received: from azsmsx501.amr.corp.intel.com ([10.2.167.99]) by azsmsx001.amr.corp.intel.com ([10.2.167.98]) with mapi; Sun, 21 Sep 2008 11:05:37 -0700 From: "Harrison, John R" To: OCaml Cc: "Harrison, John R" Date: Sun, 21 Sep 2008 11:05:36 -0700 Subject: camlp4 module dependencies Thread-Topic: camlp4 module dependencies Thread-Index: AckcFKYm9lJ6SiLRROuyODl81DOuVA== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam: no; 0.00; camlp:01 dependencies:01 camlp:01 syntax:01 parser:01 parser:01 expr:01 expr:01 syntax:01 ocamlc:01 -pp:01 parsers:01 toplevel:01 johnh:01 ocaml:01 I'm trying once again to make some code work under the new camlp4. I don't want to make any real syntax modifications, but just enable quotations performing a simple string transformation on the body of the quotation, e.g. turning <> into default_parser "hello /\\ world" About a year ago, Nicolas Pouillard gave me a recipe, which I've now put in the following form for my actual requirements: open Camlp4.PreCast;; module Caml =3D Camlp4OCamlParser.Make (Camlp4OCamlRevisedParser.Make (Camlp4.OCamlInitSyntax.Make(Ast)(Gram)(Quotation)));; let quotexpander s =3D if String.sub s 0 1 =3D "|" & String.sub s (String.length s - 1) 1 =3D = "|" then "secondary_parser \""^ (String.escaped (String.sub s 1 (String.length s - 2)))^"\"" else "default_parser \""^(String.escaped s)^"\"";; 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_quotexpan= der; Syntax.Quotation.add "" Syntax.Quotation.DynAst.str_item_tag str_item_quotexpander; Syntax.Quotation.add "" Syntax.Quotation.DynAst.patt_tag patt_quotexpan= der;; I can directly compile this file (say "Quotexpander.ml") with ocamlc -pp camlp4of -I +camlp4 -I +camlp4/Camlp4Parsers -a -o Quotexpande= r.cma Quotexpander.ml and then use it inside the toplevel without problems: /home/johnh/temp/OCaml$ ocaml Objective Caml version 3.10.0 # #load "camlp4o.cma";; Camlp4 Parsing version 3.10.0 # #load "Quotexpander.cma";; # let default_parser s =3D s;; val default_parser : 'a -> 'a =3D # <>;; - : string =3D "hello /\\ world" However, to keep the build process as trivial as possible, I'd like simply to copy the ML code directly into the toplevel (i.e. #use "Quotexpander.ml"). Doing this seems to hit some module dependencies, e.g. $ ocaml Objective Caml version 3.10.0 # #load "camlp4o.cma";; Camlp4 Parsing version 3.10.0 # open Camlp4.PreCast;; # module Caml =3D Camlp4OCamlParser.Make (Camlp4OCamlRevisedParser.Make (Camlp4.OCamlInitSyntax.Make(Ast)(Gram)(Quotation)));; Unbound module Camlp4OCamlParser.Make ... Can anyone tell me what else I should be loading/opening? John.