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.4 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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 98E91BBCA for ; Fri, 4 Apr 2008 15:42:03 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.25,604,1199660400"; d="asc'?scan'208";a="10431372" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail1-relais-roc.national.inria.fr with SMTP; 04 Apr 2008 15:42:03 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Fri, _d Apr 2008 15:40:43 +0200 From: "Nicolas Pouillard" Cc: Caml_mailing list Subject: Re: [Caml-list] Camlp4: example/parse_files.ml To: Hendrik Tews References: <18420.4901.506029.744640@tandem.cs.ru.nl> <1207236568-sup-3680@port-ext16.ensta.fr> In-Reply-To: Date: Fri, 04 Apr 2008 15:40:36 +0200 Message-Id: <1207316266-sup-9155@ausone.inria.fr> User-Agent: Sup/git Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="=-1207316443-886147-97874-3508-2-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Spam: no; 0.00; camlp:01 hendrik:01 camlp:01 syntax:01 parser:01 parser:01 syntax:01 followup:01 grammars:01 sig:01 struct:01 struct:01 parses:01 ocaml:01 parses:01 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1207316443-886147-97874-3508-2-= Content-Type: text/plain; charset=UTF-8 Excerpts from Hendrik Tews's message of Thu Apr 03 23:24:17 +0200 2008: > "Nicolas Pouillard" writes: > > > Do I miss > > something if I simplify further to > > > > module Caml = > > Camlp4OCamlParser.Make > > (Camlp4OCamlRevisedParser.Make(Camlp4.PreCast.Syntax)) > > You are applying original and revised parser, so if the > current parser is empty that's ok. Otherwise the extension can > fail. > > Right, I missed that: With this simplification I am not starting > with a fresh and empty grammar but with whatever has accumulated > in PreCast.Syntax. Yes. > > I have a followup question. With the functorial interface I can > build and use several grammars at the same time. For instance Yes. > module FreshGrammar(Unit : sig end) = > Camlp4.OCamlInitSyntax.Make > (Camlp4.PreCast.Ast)(Camlp4.PreCast.Gram)(Camlp4.PreCast.Quotation) > > module G1 = FreshGrammar(struct end) > module M1 = Camlp4OCamlRevisedParser.Make(G1) > module M2 = Camlp4OCamlParser.Make(G1) > > module G2 = FreshGrammar(struct end) > module M3 = Camlp4OCamlRevisedParser.Make(G2) > module M4 = Camlp4MacroParser.Make(G2) > > Now G1.parse_implem parses Ocaml syntax, while G2.parse_implem > parses revised syntax with macros. Yes. > Can I do the same with a syntax extention that is only loaded at > runtime via Dynlink? Assume a syntax extention X that is only > available at runtime and not at compiletime. After loading X with > Dynlink, all I can do is invoke the callback of X, but this will > add the grammar extension of X to Camlp4.PreCast.Syntax. You can do it but you will to resort to some kind of registering of your extensions, as it's done in camlp4 for the default grammar. > Is there a way to obtain two functions parse_implem (as above) > that mix X with different syntaxes (eg Ocaml + X and > Revised + X)? For that, I believe, it would be necessary to > extract parse_implem from a syntax module such that it survives > clearing that Syntax. Yes but your extension X has to be a functor, then you can get X(OCamlOriginal), X(OCamlRevised). -- Nicolas Pouillard aka Ertai --=-1207316443-886147-97874-3508-2-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkf2L9QACgkQj+FCNw9dwLm9YACfSL4vN3KtWFQB/slkGsxq3VTY /xwAnRq0NsQmRCljUFL5Ko9323qX0sgX =n7ZN -----END PGP SIGNATURE----- --=-1207316443-886147-97874-3508-2-=--