Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Caml-list] Pretty-printing the OCaml AST from the toplevel

178 views
Skip to first unread message

Joel Reymont

unread,
Oct 8, 2007, 6:58:37 AM10/8/07
to Caml List
Are there any examples of pretty-printing the OCaml AST from the
toplevel?

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.

Thanks, Joel

--
http://wagerlabs.com

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Nicolas Pouillard

unread,
Oct 8, 2007, 8:51:20 AM10/8/07
to joelr1, caml-list
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

0 new messages