From 856f366c640c44f35a0d06e707e354caeea9d836 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Tue, 23 Jan 2024 21:33:30 -0600 Subject: Adds relational operators. --- discocaml/draw_tree.ml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'discocaml/draw_tree.ml') diff --git a/discocaml/draw_tree.ml b/discocaml/draw_tree.ml index 08a8288..685ef52 100644 --- a/discocaml/draw_tree.ml +++ b/discocaml/draw_tree.ml @@ -25,6 +25,9 @@ let add_node (fmt : Format.formatter) (i : expr index) (expr : expr) : unit = | 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 + | Prim (RelOp, (op, _, _)) -> + Format.fprintf fmt " expr%d [label=\"%s\"];\n" i.index + (string_of_relop op) | Var x -> Format.fprintf fmt " expr%d [label=%S];\n" i.index x let add_expr_edges (ast : 'a ast) (fmt : Format.formatter) @@ -64,6 +67,9 @@ let add_expr_edges (ast : 'a ast) (fmt : Format.formatter) | Prim (Mul, (l, r)) -> edge_to l; edge_to r + | Prim (RelOp, (_, l, r)) -> + edge_to l; + edge_to r | Var _ -> () | Bool _ | Int _ | Nil -> () in -- cgit v1.2.3