Skip to content

Commit

Permalink
dune fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
reb-ddm committed Jan 9, 2025
1 parent 8b47e4e commit f7c5782
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/KaSa_rep/frontend/cckappa_sig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ type compil = {
(*initial graph declaration*)
perturbations:
(mixture, rule) Ckappa_sig.perturbation Int_storage.Nearly_inf_Imperatif.t;
guard_params: string list;(*rTODO make this a Int_storage not a list*)
guard_params: string list; (*rTODO make this a Int_storage not a list*)
}

(*******************************************************)
Expand Down
12 changes: 9 additions & 3 deletions core/KaSa_rep/frontend/handler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ let info_of_rule parameters ?(with_rates = false) ?(original = false) error
| false, false -> rule.Cckappa_sig.e_rule_rule.Ckappa_sig.ast_no_rate
in
let guard_params = compiled.Cckappa_sig.guard_params in
let guard = Option.map (LKappa_compiler.guard_param_to_string guard_params) rule.Cckappa_sig.e_rule_c_rule.Cckappa_sig.guard in
let guard =
Option.map
(LKappa_compiler.guard_param_to_string guard_params)
rule.Cckappa_sig.e_rule_c_rule.Cckappa_sig.guard
in
error, (label, position, direction, ast, guard, rule_id)

let hide rule = { rule with Public_data.rule_hidden = true }
Expand Down Expand Up @@ -326,10 +330,12 @@ let string_of_info ?(with_rule = true) ?(with_rule_name = true)
let guard =
match guard with
| None -> ""
| Some guard -> "#[" ^ LKappa.string_of_guard guard ^ "]" in
| Some guard -> "#[" ^ LKappa.string_of_guard guard ^ "]"
in
let s =
match label, pos, ast, id with
| "", "", "", s | "", "", s, _ | "", s, "", _ | s, "", _, _ -> prefix ^ guard ^ s
| "", "", "", s | "", "", s, _ | "", s, "", _ | s, "", _, _ ->
prefix ^ guard ^ s
| "", s2, s1, _ | s1, s2, _, _ -> prefix ^ guard ^ s1 ^ " (" ^ s2 ^ ")"
in
s
Expand Down
2 changes: 1 addition & 1 deletion core/KaSa_rep/frontend/preprocess.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2329,7 +2329,7 @@ let translate_c_compil parameters error handler compil =
Cckappa_sig.observables = c_observables;
Cckappa_sig.init = c_inits;
Cckappa_sig.perturbations = c_perturbations;
Cckappa_sig.guard_params = guard_params;
Cckappa_sig.guard_params;
} )

let declare_agent parameters error ag sol =
Expand Down
7 changes: 6 additions & 1 deletion core/KaSa_rep/remanent_state/remanent_state.mli
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ type var_id = int
type dead_agents = Public_data.agent_kind list

val info_to_rule :
string * Loc.t * Public_data.rule_direction * string * string LKappa.guard option * Ckappa_sig.c_rule_id ->
string
* Loc.t
* Public_data.rule_direction
* string
* string LKappa.guard option
* Ckappa_sig.c_rule_id ->
Public_data.rule

val info_to_agent :
Expand Down
28 changes: 17 additions & 11 deletions core/grammar/lKappa_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2538,19 +2538,25 @@ let rec guard_param_conversion convert guard_params g =
| Param p -> Param (convert p guard_params)
| Not g1 -> Not (guard_param_conversion convert guard_params g1)
| And (g1, g2) ->
And (guard_param_conversion convert guard_params g1, guard_param_conversion convert guard_params g2)
And
( guard_param_conversion convert guard_params g1,
guard_param_conversion convert guard_params g2 )
| Or (g1, g2) ->
Or (guard_param_conversion convert guard_params g1 , guard_param_conversion convert guard_params g2)

let guard_param_to_int = guard_param_conversion (fun p guard_params -> match List.find_index (fun x -> String.equal p x) guard_params with
| Some i -> i
| None ->
raise
(ExceptionDefn.Malformed_Decl ("Unknown guard parameter", Loc.dummy)))
Or
( guard_param_conversion convert guard_params g1,
guard_param_conversion convert guard_params g2 )

let guard_param_to_int =
guard_param_conversion (fun p guard_params ->
match List.find_index (fun x -> String.equal p x) guard_params with
| Some i -> i
| None ->
raise
(ExceptionDefn.Malformed_Decl ("Unknown guard parameter", Loc.dummy)))

let guard_param_to_string = guard_param_conversion (fun p guard_params ->
List.nth guard_params p (*rTODO error handling*)
)
let guard_param_to_string =
guard_param_conversion (fun p guard_params ->
List.nth guard_params p (*rTODO error handling*))

let guard_params_to_int_option guard_params g =
Option.map (guard_param_to_int guard_params) g
Expand Down
2 changes: 1 addition & 1 deletion core/term/lKappa.ml
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ let rec string_of_guard g =
| Param i -> i
| And (a, b) -> string_of_guard a ^ " && " ^ string_of_guard b
| Or (a, b) -> string_of_guard a ^ " || " ^ string_of_guard b
| Not a -> "[not] " ^ string_of_guard a
| Not a -> "[not] " ^ string_of_guard a

let rec print_guard f g =
match g with
Expand Down

0 comments on commit f7c5782

Please sign in to comment.