diff options
Diffstat (limited to 'discocaml/ast.ml')
-rw-r--r-- | discocaml/ast.ml | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/discocaml/ast.ml b/discocaml/ast.ml index 63893fa..92ac32d 100644 --- a/discocaml/ast.ml +++ b/discocaml/ast.ml @@ -161,3 +161,10 @@ let parsetree_of_subexpr (ast : 'a ast) : expr -> Parsetree.expression = let parsetree_of_expr (ast : expr ast) : Parsetree.expression = parsetree_of_subexpr ast (get_subexpr ast ast.root) + +let show_expr (expr : expr ast) : string = + let buf = Buffer.create 16 in + let fmt = Format.formatter_of_buffer buf in + Pprintast.expression fmt (parsetree_of_expr expr); + Format.pp_print_flush fmt (); + Buffer.contents buf |