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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 1F1A5BC6B for ; Wed, 10 Oct 2007 14:37:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAEpkDEfAXQInh2dsb2JhbACOSAIBCAop X-IronPort-AV: E=Sophos;i="4.21,254,1188770400"; d="scan'208";a="17797215" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 10 Oct 2007 14:37:22 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9ACbJwk027126 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 10 Oct 2007 14:37:22 +0200 X-IronPort-AV: E=Sophos;i="4.21,254,1188770400"; d="scan'208";a="17797213" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail4-relais-sop.national.inria.fr with SMTP; 10 Oct 2007 14:37:22 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Wed, _d Oct 2007 14:36:50 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] camlp4: From AST to shortcuts To: joelr1 References: <97183C23-C2CB-4915-B406-798B8ABB0E0D@gmail.com> In-Reply-To: <97183C23-C2CB-4915-B406-798B8ABB0E0D@gmail.com> Date: Wed, 10 Oct 2007 14:36:50 +0200 Message-Id: <1192019175-sup-5153@port-ext2.ensta.fr> User-Agent: Sup/0.1 Content-Type: text/plain; charset=utf-8 X-j-chkmail-Score: MSGID : 470CC77F.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 470CC77F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 ctyp:01 ocaml:01 ocaml:01 syntax:01 syntax:01 eprintf:01 ctyp:01 wiki:01 wiki:01 camlcvs:01 cvsweb:01 1.3:98 partial:01 Excerpts from joelr1's message of Tue Oct 09 23:41:14 +0200 2007: > Suppose I'm debugging a camlp4 extension and get the following AST > > Ast.TyId (_loc, Ast.IdLid (_loc, "int")) > > what's the best way of figuring out that this correspods to this bit? > > <:ctyp< int >> With the pretty printer. It starts like the last time. $ rlwrap ocaml camlp4of.cma open Camlp4.PreCast;; module PP = Camlp4.Printers.OCaml.Make(Syntax);; let pp = new PP.printer ();; let ghost = Loc.ghost;; module PP = Camlp4.Printers.OCaml.Make(Syntax);; let _loc = ghost;; Format.eprintf "<:ctyp< %a >>@." pp#ctyp (Ast.TyId (_loc, Ast.IdLid (_loc, "int")));; > Do I grep the sources and if so what files? In fact you should look at the wiki first especially the Abstract_Syntax_Tree [3] page. The wiki also states about "Relevant Source Files" [2]. In this case the most relevant file is Camlp4Ast.partial.ml [1]. [1]: http://camlcvs.inria.fr/cgi-bin/cvsweb/ocaml/camlp4/Camlp4/Camlp4Ast.partial.ml?rev=1.3;content-type=text%2Fplain [2]: http://brion.inria.fr/gallium/index.php/Relevant_Source_Files [3]: http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree > This is a rather simple example but I'm trying to teach myself to > fish. Ultimately, I want to add initializer code and fields to the > AST resulting from a class declaration. See my other mail about class initializer. Good fishing... -- Nicolas Pouillard aka Ertai