diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-01-20 00:00:17 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-01-20 00:00:17 -0600 |
commit | 514896e05424d9df97295840b3fa6f2ad46620ab (patch) | |
tree | f69abbb4971a3bf9cc4ca3152b8f6cc141069cc8 /discocaml/draw_tree.ml | |
parent | 738f437f59bf2408dcdc6514ffa2d7a2ee5a61c5 (diff) |
Adds lists, although they don't evaluate yet.
Diffstat (limited to 'discocaml/draw_tree.ml')
-rw-r--r-- | discocaml/draw_tree.ml | 13 |
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 |