[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Nicolas Pouillard <nicolas.pouillard@i...> |
| Subject: | Re: [Caml-list] camlp4: From AST to shortcuts |
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