Version française
Home     About     Download     Resources     Contact us    
Browse thread
Pretty-printing the OCaml AST from the toplevel
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nicolas Pouillard <nicolas.pouillard@i...>
Subject: Re: [Caml-list] Pretty-printing the OCaml AST from the toplevel
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