aboutsummaryrefslogtreecommitdiff
path: root/discocaml/draw_tree.ml
diff options
context:
space:
mode:
Diffstat (limited to 'discocaml/draw_tree.ml')
-rw-r--r--discocaml/draw_tree.ml8
1 files changed, 8 insertions, 0 deletions
diff --git a/discocaml/draw_tree.ml b/discocaml/draw_tree.ml
index 4b1688b..3429a71 100644
--- a/discocaml/draw_tree.ml
+++ b/discocaml/draw_tree.ml
@@ -13,6 +13,9 @@ let add_node (fmt : Format.formatter) (i : expr index) (expr : expr) : unit =
i.index
| Int n -> Format.fprintf fmt " expr%d [label=\"%d\"];\n" i.index n
| Lam _ -> Format.fprintf fmt " expr%d [label=\"λ\"];\n" i.index
+ | Let (recursive, _, _, _) ->
+ Format.fprintf fmt " expr%d [label=\"%s\"];\n" i.index
+ (if recursive then "letrec" else "let")
| Nil ->
Format.fprintf fmt
" expr%d [fontname=\"CMU Typewriter Text Bold\", label=\"[]\"];\n"
@@ -41,6 +44,11 @@ let add_expr_edges (ast : 'a ast) (fmt : Format.formatter)
Format.fprintf fmt " expr%d -> expr%d_var;\n" i.index i.index;
Format.fprintf fmt " expr%d_var [label=%S];\n" i.index x;
edge_to b
+ | Let (_, name, bound, body) ->
+ Format.fprintf fmt " expr%d -> expr%d_var;\n" i.index i.index;
+ Format.fprintf fmt " expr%d_var [label=%S];\n" i.index name;
+ edge_to bound;
+ edge_to body
| Prim (Add, (l, r)) ->
edge_to l;
edge_to r