Skip to content

Commit

Permalink
add guard parameters to kappa_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
reb-ddm committed Dec 11, 2024
1 parent b065762 commit 656c969
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/KaSa_rep/frontend/cckappa_sig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type kappa_handler = {
Ckappa_sig
.Agent_type_site_state_nearly_Inf_Int_Int_Int_storage_Imperatif_Imperatif_Imperatif
.t;
guard_parameters: string list;
}

type 'a interval = { min: 'a option; max: 'a option }
Expand Down
1 change: 1 addition & 0 deletions core/KaSa_rep/frontend/cckappa_sig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type kappa_handler = {
Ckappa_sig
.Agent_type_site_state_nearly_Inf_Int_Int_Int_storage_Imperatif_Imperatif_Imperatif
.t;
guard_parameters: string list;
}

type 'a interval = { min: 'a option; max: 'a option }
Expand Down
23 changes: 19 additions & 4 deletions core/KaSa_rep/frontend/list_tokens.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ let empty_handler parameters error =
Cckappa_sig.sites;
Cckappa_sig.states_dic;
Cckappa_sig.dual;
Cckappa_sig.guard_parameters = [];
} )

let create_binding_state_dictionary parameters error =
Expand Down Expand Up @@ -428,6 +429,18 @@ let scan_perts scan_mixt parameters =
remanent)
remanent m)

let scan_guard (error, handler) guard =
match guard with
| None -> error, handler
| Some guard ->
let guard_parameters = Ast.guard_params_from_guard guard in
( error,
{
handler with
Cckappa_sig.guard_parameters =
Ast.merge_guards guard_parameters handler.Cckappa_sig.guard_parameters;
} )

let scan_rules scan_mixt parameters a b =
let _ =
if Remanent_parameters.get_trace parameters then (
Expand All @@ -443,10 +456,12 @@ let scan_rules scan_mixt parameters a b =
)
in
List.fold_left
(fun remanent (_, _, (rule, _)) ->
scan_mixture parameters
(scan_mixt parameters remanent rule.Ckappa_sig.lhs)
rule.Ckappa_sig.rhs)
(fun remanent (_, guard, (rule, _)) ->
scan_guard
(scan_mixture parameters
(scan_mixt parameters remanent rule.Ckappa_sig.lhs)
rule.Ckappa_sig.rhs)
guard)
a b

let reverse_agents_annotation parameters (error, remanent) =
Expand Down
3 changes: 3 additions & 0 deletions core/grammar/ast.mli
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ val split_mixture : mixture -> mixture * mixture
val infer_agent_signatures : parsing_compil -> parsing_compil
(** Used when agent signatures is implicit: infer agent signatures and tokens from init, rules and perturbations *)

val merge_guards : string list -> string list -> string list
val guard_params_from_guard : string LKappa.guard -> string list

val get_list_of_guard_parameters :
(string Loc.annoted option * string LKappa.guard option * 'rule Loc.annoted)
list ->
Expand Down

0 comments on commit 656c969

Please sign in to comment.