From c2638e5d17b93e79851da8c43a377b7d51e723bc Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Tue, 23 Jan 2024 23:22:37 -0600 Subject: Draw edges for the binding structure. --- discocaml/draw_tree.ml | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'discocaml/draw_tree.ml') diff --git a/discocaml/draw_tree.ml b/discocaml/draw_tree.ml index 16719df..f0badd7 100644 --- a/discocaml/draw_tree.ml +++ b/discocaml/draw_tree.ml @@ -88,13 +88,24 @@ let draw_tree (ast : expr ast) : string = let fmt = Format.formatter_of_buffer buf in Format.fprintf fmt "digraph {\n"; Format.fprintf fmt " node [shape=\"box\", style=\"rounded\"];\n"; + add_expr_edges ast fmt nodes ast.root; Format.fprintf fmt "\n"; + IntSet.iter (fun index -> let i = { index } in add_node fmt i (get_subexpr ast i)) !nodes; + + get_binders ast + |> Array.iteri (fun i -> function + | Some j -> + Format.fprintf fmt + " expr%d -> expr%d_var [color=\"#cccccc\", constraint=false];\n" i + j.index + | None -> ()); + Format.fprintf fmt "}\n"; Format.pp_print_flush fmt (); Buffer.contents buf -- cgit v1.2.3