Camlp4 tricks


This is a place to share tips and tricks about Camlp4.

 

AST to string conversion

 

This message from Daniel de Rauglaudre on caml-list explains how to convert a syntax node into a string, like pr_o.cmo or pr_r.cmo do.

 

Basically, pretty-printing an expr e goes like this:

Pcaml.string_of Pcaml.pr_expr e

The Pr_o (or Pr_r) module has to be linked in.