diff options
author | Nathan Ringo <nathan@remexre.com> | 2024-01-23 21:16:41 -0600 |
---|---|---|
committer | Nathan Ringo <nathan@remexre.com> | 2024-01-23 21:16:41 -0600 |
commit | e14527d0a550a48c8ac6c25d9e4fb143a0019f06 (patch) | |
tree | c9f29a691076c645fb63b68a40650072b0521825 /discocaml/draw_tree.ml | |
parent | 6b1b1abafff15c5021d33689335e9b792c1873d4 (diff) |
Booleans and if.
Diffstat (limited to 'discocaml/draw_tree.ml')
-rw-r--r-- | discocaml/draw_tree.ml | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/discocaml/draw_tree.ml b/discocaml/draw_tree.ml index 3429a71..08a8288 100644 --- a/discocaml/draw_tree.ml +++ b/discocaml/draw_tree.ml @@ -7,10 +7,12 @@ 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 + | Bool b -> Format.fprintf fmt " expr%d [label=\"%b\"];\n" i.index b | Cons _ -> Format.fprintf fmt " expr%d [fontname=\"CMU Typewriter Text Bold\", label=\"::\"];\n" i.index + | If (_, _, _) -> Format.fprintf fmt " expr%d [label=\"if\"];\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 | Let (recursive, _, _, _) -> @@ -40,6 +42,10 @@ let add_expr_edges (ast : 'a ast) (fmt : Format.formatter) | Cons (hd, tl) -> edge_to hd; edge_to tl + | If (cond, then_, else_) -> + edge_to cond; + edge_to then_; + edge_to else_ | 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; @@ -59,7 +65,7 @@ let add_expr_edges (ast : 'a ast) (fmt : Format.formatter) edge_to l; edge_to r | Var _ -> () - | Int _ | Nil -> () + | Bool _ | Int _ | Nil -> () in loop |