From ed686f7c7fdce0c3062a2859e32e974c096246df Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Fri, 19 Jan 2024 19:56:39 -0600 Subject: Add notes to eval output. --- discocaml/ast.ml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'discocaml/ast.ml') 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 -- cgit v1.2.3