From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q12GdCMo022559 for ; Thu, 2 Feb 2012 17:39:12 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjIBAFW7Kk9KfVK2kGdsb2JhbAApGoULqXkIIgEBAQEJCQ0HFAQhgXIBAQEEEgIPHQEbHQEDDAYDAgsNAgImAgIhAQERAQUBHAYTIodjKZpjCosmSoJwhRQ/iHECBQuBJIZJg1gHAgICCAEBBA0EBgEBASsMAoQnC4JCgRYElSOLBQODED2EAQ X-IronPort-AV: E=Sophos;i="4.71,609,1320620400"; d="scan'208";a="142601764" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 02 Feb 2012 17:39:07 +0100 Received: by werm13 with SMTP id m13so3512655wer.27 for ; Thu, 02 Feb 2012 08:39:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=MTHszGlKmUbsn0CVqMI1nhbK8aW54Oy0iGQBu7KO6as=; b=MfiX2Q2nj2DrSIkOnMpD86AMgHaq+vFdKAQOEUC7uOpfV+8FL9A/j2OFOSkXLT24FN Fhr2zWrnXu3nrelGXaar1wlptDxvqJZnPmMBEj1cYvZWSDjFE4A6QiDqaNV3alj/sy19 /sCqk218I4VZgWVGaMXo3OtYSPaDs7bF0/qKU= Received: by 10.216.133.132 with SMTP id q4mr5033235wei.12.1328200746821; Thu, 02 Feb 2012 08:39:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.42.208 with HTTP; Thu, 2 Feb 2012 08:38:24 -0800 (PST) In-Reply-To: <4F292986.30008@gmail.com> References: <4F285C76.10301@gmail.com> <4F292986.30008@gmail.com> From: Gabriel Scherer Date: Thu, 2 Feb 2012 17:38:24 +0100 Message-ID: To: =?UTF-8?B?TWF0ZWogS2/FocOtaw==?= <5764c029b688c1c0d24a2e97cd764f@gmail.com> Cc: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q12GdCMo022559 Subject: Re: [Caml-list] how (within camlp4 printer) can I traverse AST ? I think that just replacing Camlp4.Sig.Syntax and Camlp4.Register.Printer by Camlp4.Sig.Camlp4Syntax and Camlp4.Register.OCamlPrinter works. I'm not sure what you mean by "using concrete instead of abstract syntax"; if you mean using quotations instead of writing the AST constructor names in full, then that is not related to printers specifically. Feel free to look at existing syntax extensions, such as http://bluestorm.info/camlp4/list.php , for inspiration. But none of them, if I remember correctly, touch the printers. On Wed, Feb 1, 2012 at 1:01 PM, Matej Košík <5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote: > On 01/31/2012 10:58 PM, Gabriel Scherer wrote: >> Sig.Ast is the most general structure available, that you use if you >> want to manipulate any kind of grammar for Camlp4. If you know the AST >> you're manipulating corresponds to an OCaml program, you should use >> the more specific Sig.Camlp4Ast signature (as advertized in the >> documentation page for Sig.Ast, btw.). Registering a printer for >> Sig.Camlp4Ast is done with Register.OcamlPrinter, and if you want to >> see a full-blown example of printer, you just have too look at >> camlp4/Camlp4/Printers/OCaml.ml in the ocaml source. > > Thank you. > > Concerning camlp4/Camlp4/Printers*.ml I am struggling with two problems: > > 1. these examples are not compiled with ordinary ocamlc/camlp4 tools but > with special ocamlc/camlp4* version built at the "boot time" which are > not interchangeable with regular ocamlc/camlp4* programs. If I try to > use regular ocamlc/camlp4* tools in an attempt to compile those > printers, I will get syntax errors in those printers. > > 2. the code that registers the printers is not in printers themselves > but it is located in another file, in another context and it is not > obvious how to achieve this action in the context of the code of > individual printers (in an analogous way how sample printer >  http://brion.inria.fr/gallium/index.php/Setup_a_new_printer > directly registers itself. > > How would the printer described here: >  http://brion.inria.fr/gallium/index.php/Setup_a_new_printer > look like if I wanted to use concrete instead of abstract syntax---like in: > - DumpOCamlAst > - OCaml.ml > - OCamlr.ml > ? > > (So that presumably I can compile the printer as shown in the HOWTO.)