diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-01-23 23:22:37 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-01-23 23:22:37 -0600 |
commit | c2638e5d17b93e79851da8c43a377b7d51e723bc (patch) | |
tree | e4dac1716cd5b0f69b1f53afcbeb61af39ccc8cb /discocaml/draw_tree.ml | |
parent | d32d8e09b5763efda69b93139d29147af7a47e71 (diff) |
Draw edges for the binding structure.
Diffstat (limited to 'discocaml/draw_tree.ml')
-rw-r--r-- | discocaml/draw_tree.ml | 11 |
1 files changed, 11 insertions, 0 deletions
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 |