Skip to content

Commit

Permalink
defined print function for guards
Browse files Browse the repository at this point in the history
  • Loading branch information
reb-ddm committed Dec 9, 2024
1 parent f0cfd4c commit d65293f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions core/grammar/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions core/term/lKappa.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 "@[<h>%t%t%t%a%t@]"
(fun f ->
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit d65293f

Please sign in to comment.