From d65293f7307ab9a1f58db2bd720f0b4fb29c50d5 Mon Sep 17 00:00:00 2001 From: Rebecca Ghidini Date: Mon, 9 Dec 2024 10:07:49 +0100 Subject: [PATCH] defined print function for guards --- core/grammar/ast.ml | 9 +++++---- core/term/lKappa.ml | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/grammar/ast.ml b/core/grammar/ast.ml index 41c3870d8..9ccb8b297 100644 --- a/core/grammar/ast.ml +++ b/core/grammar/ast.ml @@ -1137,12 +1137,13 @@ let print_parsing_compil_kappa f c = (Pp.list Pp.space (fun f (a, _) -> Format.fprintf f "@[%%plot:@ @[%a@]@]" print_ast_alg_expr a)) c.observables - (Pp.list Pp.space (fun f (s, _guard (*TODO*), (r, _)) -> - (*TODO print g*) - Format.fprintf f "@[@[%a%a@]@]" + (Pp.list Pp.space (fun f (s, guard, (r, _)) -> + Format.fprintf f "@[@[%a%a%a@]@]" (Pp.option ~with_space:false (fun f (s, _) -> Format.fprintf f "'%s'@ " s)) - s print_ast_rule r)) + s + (Pp.option ~with_space:false LKappa.print_guard) + guard print_ast_rule r)) c.rules (Pp.list Pp.space print_perturbation) c.perturbations diff --git a/core/term/lKappa.ml b/core/term/lKappa.ml index 37119d709..718f6df90 100644 --- a/core/term/lKappa.ml +++ b/core/term/lKappa.ml @@ -510,7 +510,6 @@ let print_rates ~noCounters sigs counters_info pr_tok pr_var f r = max_dist) let rec print_guard f g = - (*rTODO test*) match g with | True -> Format.fprintf f "TRUE" | False -> Format.fprintf f "FALSE" @@ -519,6 +518,9 @@ let rec print_guard f g = | Or (a, b) -> Format.fprintf f "@[(%a || %a)@]" print_guard a print_guard b | Not a -> Format.fprintf f "@[[not] %a@]" print_guard a +let print_guard f g = + Format.fprintf f "/*if*/ %a /*then*/@ " print_guard g + let print_rule ~noCounters ~full sigs counters_info pr_tok pr_var f r = Format.fprintf f "@[%t%t%t%a%t@]" (fun f -> @@ -694,7 +696,7 @@ let rule_of_json ~filenames = function (List.assoc "unary_rate" l) with Not_found -> None); r_edit_style = Yojson.Basic.Util.to_bool (List.assoc "edit_style" l); - r_guard = None (*TODO List.assoc_opt "guard" l;*); + r_guard = None (*rTODO List.assoc_opt "guard" l;*); } with Not_found -> raise (Yojson.Basic.Util.Type_error ("Incorrect rule", x)))