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 q11C1HeX028982 for ; Wed, 1 Feb 2012 13:01:17 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsoFAE0oKU/RVdY2kGdsb2JhbAApGoIoZYF+qWgIIgEBAQEJCQ0HFAQhgXIBAQEEEgIPHQEbHQEDDAYFCw0CAgUhAgIPAhIRAQUBHAYNAQcBAR6HXQYpm04KiyZIgnCFBj+IcQIFC4EkiXQEAQUBAQECAQUCAgIIAQEEDQQGAUeCchkEAwwDFAVXCoJNgRYElSGFV4E5hwc9hAA X-IronPort-AV: E=Sophos;i="4.71,601,1320620400"; d="scan'208";a="142356650" Received: from mail-bk0-f54.google.com ([209.85.214.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Feb 2012 13:01:15 +0100 Received: by bkbzx1 with SMTP id zx1so1694290bkb.27 for ; Wed, 01 Feb 2012 04:01:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=YIgXBYCTCXo5OTnIKf84B5IJMTsbwBzNVLebQVc5/E4=; b=irSJv4jU5VZgeMjXg1jK1kP9eu3S3k3j/22XhyO/YOpdU6D17qd9C+sLCrdpvRhsoK cM8lZdC3tyHdw/w8Z+ZpswAzBA+IGWfV4BvaLOPxiV+NI07Zuv60/cMz8lUtlX2gJBGY lvQGrDlo8dNwFGewD5+6NsHfc6aEffG7vVYMU= Received: by 10.205.127.17 with SMTP id gy17mr12383771bkc.110.1328097675435; Wed, 01 Feb 2012 04:01:15 -0800 (PST) Received: from [192.168.1.24] (188.29.74.65.threembb.co.uk. [188.29.74.65]) by mx.google.com with ESMTPS id z15sm51021673bkd.7.2012.02.01.04.01.14 (version=SSLv3 cipher=OTHER); Wed, 01 Feb 2012 04:01:15 -0800 (PST) Message-ID: <4F292986.30008@gmail.com> Date: Wed, 01 Feb 2012 12:01:10 +0000 From: =?UTF-8?B?TWF0ZWogS2/FocOtaw==?= <5764c029b688c1c0d24a2e97cd764f@gmail.com> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: Gabriel Scherer CC: caml-list@inria.fr References: <4F285C76.10301@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] how (within camlp4 printer) can I traverse AST ? 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.)