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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id B4ABABC6B for ; Mon, 8 Oct 2007 14:50:24 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAN7DCUfAXQImh2dsb2JhbACOQwIBCAop X-IronPort-AV: E=Sophos;i="4.21,242,1188770400"; d="scan'208";a="2621264" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 Oct 2007 14:50:24 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l98CoEFv017952 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 8 Oct 2007 14:50:24 +0200 X-IronPort-AV: E=Sophos;i="4.21,242,1188770400"; d="scan'208";a="2438413" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail1-relais-roc.national.inria.fr with SMTP; 08 Oct 2007 14:50:24 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Mon, _d Oct 2007 14:49:53 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] Pretty-printing the OCaml AST from the toplevel To: joelr1 References: <939CC7FB-3889-49BE-90BC-77491658409C@gmail.com> In-Reply-To: <939CC7FB-3889-49BE-90BC-77491658409C@gmail.com> Date: Mon, 08 Oct 2007 14:49:52 +0200 Message-Id: <1191847701-sup-5705@ausone.inria.fr> User-Agent: Sup/0.1 Content-Type: text/plain; charset=utf-8 X-j-chkmail-Score: MSGID : 470A2786.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 470A2786.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 toplevel:01 ocaml:01 toplevel:01 camlp:01 camlp:01 syntax:01 syntax:01 eprintf:01 expr:01 expr:01 foo:01 caml-list:01 cma:01 ast:02 Excerpts from joelr1's message of Mon Oct 08 12:57:56 +0200 2007: > Are there any examples of pretty-printing the OCaml AST from the > toplevel? $ 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);; Format.eprintf "%a@." pp#expr <:expr@ghost< 3 + 4 >>;; > I'm looking to use this during interactive debugging. > > I see the following example in the camlp4 changes doc > > camlp4 -parser OCaml -printer OCamlr foo.ml > > but I'm still browsing through Camlp4.ml to figure out what that does > exactly. Camlp4.ml is a generated file. It's perhaps not the best way to read camlp4 sources. -- Nicolas Pouillard aka Ertai