From 79c4e2a581afc02527f71c8091abeb5a5c08945d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20G=C3=A9rard?= Date: Mon, 2 Aug 2010 16:32:40 +0200 Subject: [PATCH] Print causality constraints in a human readable shape. --- compiler/heptagon/analysis/causal.ml | 43 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/compiler/heptagon/analysis/causal.ml b/compiler/heptagon/analysis/causal.ml index 6b51de3..05497b0 100644 --- a/compiler/heptagon/analysis/causal.ml +++ b/compiler/heptagon/analysis/causal.ml @@ -53,28 +53,27 @@ and nc = | Aac of ac | Aempty -let output_ac ff ac = (*TODO LG fix breaks*) - let rec print priority ff ac = - fprintf ff "@["; - begin match ac with - | Aseq(ac1, ac2) -> - (if priority > 1 - then fprintf ff "(%a@ < %a)" - else fprintf ff "%a@ < %a") - (print 1) ac1 (print 1) ac2 - | Aand(ac1, ac2) -> - (if priority > 0 - then fprintf ff "(%a || %a)" - else fprintf ff "%a || %a") - (print 0) ac1 (print 0) ac2 - | Atuple(acs) -> - print_list_r (print 1) "(" "," ")" ff acs - | Awrite(m) -> fprintf ff "%s" (name m) - | Aread(m) -> fprintf ff "^%s" (name m) - | Alastread(m) -> fprintf ff "last %s" (name m) - end; - fprintf ff "@]" in - fprintf ff "@[%a@]@?" (print 0) ac +let output_ac ff ac = + let rec print priority ff ac = match ac with + | Aseq(ac1, ac2) -> (* priority 1 *) + (if priority = 1 then fprintf ff "%a@ < %a" + else if priority > 1 + then fprintf ff "@[(%a@ < %a)@]" + else fprintf ff "@[%a@ < %a@]") + (print 1) ac1 (print 1) ac2 + | Aand(ac1, ac2) -> (* priority 0 *) + (if priority = 0 then fprintf ff "%a@ || %a" + else if priority > 0 + then fprintf ff "@[(%a@ || %a)@]" + else fprintf ff "@[%a@ || %a@]") + (print 0) ac1 (print 0) ac2 + | Atuple(acs) -> + fprintf ff "@[%a@]" (print_list_r (print 1) "(" "," ")") acs + | Awrite(m) -> fprintf ff "%s" (name m) + | Aread(m) -> fprintf ff "^%s" (name m) + | Alastread(m) -> fprintf ff "last %s" (name m) + in + fprintf ff "@[%a@]@?" (print 0) ac type error = Ecausality_cycle of ac