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.ml13
1 files changed, 12 insertions, 1 deletions
diff --git a/discocaml/draw_tree.ml b/discocaml/draw_tree.ml
index 3d01412..4b1688b 100644
--- a/discocaml/draw_tree.ml
+++ b/discocaml/draw_tree.ml
@@ -7,8 +7,16 @@ let add_node (fmt : Format.formatter) (i : expr index) (expr : expr) : unit =
Format.fprintf fmt
" expr%d [fontname=\"CMU Typewriter Text Bold\", label=\"apply\"];\n"
i.index
+ | Cons _ ->
+ Format.fprintf fmt
+ " expr%d [fontname=\"CMU Typewriter Text Bold\", label=\"::\"];\n"
+ 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
+ | Nil ->
+ Format.fprintf fmt
+ " expr%d [fontname=\"CMU Typewriter Text Bold\", label=\"[]\"];\n"
+ i.index
| Prim (Add, _) -> Format.fprintf fmt " expr%d [label=\"+\"];\n" i.index
| Prim (Sub, _) -> Format.fprintf fmt " expr%d [label=\"-\"];\n" i.index
| Prim (Mul, _) -> Format.fprintf fmt " expr%d [label=\"*\"];\n" i.index
@@ -26,7 +34,9 @@ let add_expr_edges (ast : 'a ast) (fmt : Format.formatter)
| App (f, x) ->
edge_to f;
edge_to x
- | Int _ -> ()
+ | Cons (hd, tl) ->
+ edge_to hd;
+ edge_to tl
| Lam (x, b) ->
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;
@@ -41,6 +51,7 @@ let add_expr_edges (ast : 'a ast) (fmt : Format.formatter)
edge_to l;
edge_to r
| Var _ -> ()
+ | Int _ | Nil -> ()
in
loop