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 2AF94BBCA for ; Thu, 3 Apr 2008 23:24:18 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AukAACTo9EeDrhCRlmdsb2JhbACRVQEBAQEJBQkdmig X-IronPort-AV: E=Sophos;i="4.25,600,1199660400"; d="scan'208";a="10396413" Received: from smeltpunt.science.ru.nl ([131.174.16.145]) by mail1-smtp-roc.national.inria.fr with ESMTP; 03 Apr 2008 23:24:17 +0200 Received: from tandem.cs.ru.nl (tandem.cs.ru.nl [131.174.142.18]) by smeltpunt.science.ru.nl (8.13.7/5.23) with ESMTP id m33LOHTc018022 for ; Thu, 3 Apr 2008 23:24:17 +0200 (MEST) Received: from tews by tandem.cs.ru.nl with local (Exim 4.63) (envelope-from ) id 1JhWuv-0005uK-8o for caml-list@yquem.inria.fr; Thu, 03 Apr 2008 23:24:17 +0200 From: Hendrik Tews To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Camlp4: example/parse_files.ml References: <18420.4901.506029.744640@tandem.cs.ru.nl> <1207236568-sup-3680@port-ext16.ensta.fr> Date: Thu, 03 Apr 2008 23:24:17 +0200 In-Reply-To: <1207236568-sup-3680@port-ext16.ensta.fr> (Nicolas Pouillard's message of "Thu, 03 Apr 2008 17:32:55 +0200") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Scanned-By: MIMEDefang 2.63 on 131.174.16.145 X-Spam: no; 0.00; hendrik:01 tews:01 tews:01 camlp:01 camlp:01 syntax:01 parser:01 parser:01 syntax:01 followup:01 grammars:01 sig:01 struct:01 struct:01 parses:01 "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. I have a followup question. With the functorial interface I can build and use several grammars at the same time. For instance 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. 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. 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. Bye, Hendrik