aboutsummaryrefslogtreecommitdiff
path: root/discocaml/ast.ml
diff options
context:
space:
mode:
authorNathan Ringo <nathan@remexre.com>2024-01-19 19:56:39 -0600
committerNathan Ringo <nathan@remexre.com>2024-01-19 19:56:39 -0600
commited686f7c7fdce0c3062a2859e32e974c096246df (patch)
treef8790403f1fa3648f9aae0826e1d9b31a4d8d502 /discocaml/ast.ml
parenta84e462b596c24d2562d766ceb019761085390c5 (diff)
Add notes to eval output.
Diffstat (limited to 'discocaml/ast.ml')
-rw-r--r--discocaml/ast.ml7
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