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 q0VMwIpY031204 for ; Tue, 31 Jan 2012 23:59:01 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjcBAG1xKE9KfVK2kGdsb2JhbAAoGoULmRKQQggiAQEBAQkJDQcUBCGBcgEBAQQSAg8dARsSCwEDDAYDAgsNAgIJHQICIQEBEQEFAQoSBhMSEIdjKZs9CoskSIJwhH8/iHECBQuBJIlhBwICAggBAQQNBAYBAQErDAIMhBsLgkKBFgSVIIsHgxA9hAE X-IronPort-AV: E=Sophos;i="4.71,599,1320620400"; d="scan'208";a="142279302" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 31 Jan 2012 23:59:01 +0100 Received: by werm13 with SMTP id m13so799771wer.27 for ; Tue, 31 Jan 2012 14:59:01 -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=cp3F5y6kaa7+clfFs5zXcx9m2cb/q4gWPGR+wzVCF24=; b=bjuSBgSQQAHjOGPnwGirCk2r0RXr4cGQ6AjJ7YA+4f7yzUVistIIEnzk3HeoWdubX4 XWSEDYsA17+d9q8C0iatvEp8BDBEC98571L62TY/cBZF54JdM6Hy5ZFh+6YUV25eJ6Cf k0IYQ3pEfrE7WaASLIl23ymaX4DfZo+oCE878= Received: by 10.216.131.39 with SMTP id l39mr1814354wei.4.1328050741150; Tue, 31 Jan 2012 14:59:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.42.208 with HTTP; Tue, 31 Jan 2012 14:58:21 -0800 (PST) In-Reply-To: <4F285C76.10301@gmail.com> References: <4F285C76.10301@gmail.com> From: Gabriel Scherer Date: Tue, 31 Jan 2012 23:58:21 +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 q0VMwIpY031204 Subject: Re: [Caml-list] how (within camlp4 printer) can I traverse AST ? 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. On Tue, Jan 31, 2012 at 10:26 PM, Matej Košík <5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote: > Hello, > > I would like to write a (camlp4 pluggable) printer. > > My starting-point is this: > > http://brion.inria.fr/gallium/index.php/Setup_a_new_printer > > It was easy to figure out that "ast" arguments have type "Ast.sig_item" > or "Ast.str_item" respectively which are both abstract types > http://camlunity.ru/doc/camlp4-3.12/Camlp4.Sig.Ast.html > so I cannot try to match them---I cannot use any of the constructors > defined in: > > http://camlunity.ru/doc/camlp4-3.12/Camlp4.Sig.Camlp4Ast.html > > What is thus a proper way of traversing ASTs? > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >