From 656c969eec8fa8884c5e6a5692034249f85f7a9e Mon Sep 17 00:00:00 2001 From: Rebecca Ghidini Date: Wed, 11 Dec 2024 16:39:25 +0100 Subject: [PATCH] add guard parameters to kappa_handler --- core/KaSa_rep/frontend/cckappa_sig.ml | 1 + core/KaSa_rep/frontend/cckappa_sig.mli | 1 + core/KaSa_rep/frontend/list_tokens.ml | 23 +++++++++++++++++++---- core/grammar/ast.mli | 3 +++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/KaSa_rep/frontend/cckappa_sig.ml b/core/KaSa_rep/frontend/cckappa_sig.ml index a527d6adc..011841562 100644 --- a/core/KaSa_rep/frontend/cckappa_sig.ml +++ b/core/KaSa_rep/frontend/cckappa_sig.ml @@ -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 } diff --git a/core/KaSa_rep/frontend/cckappa_sig.mli b/core/KaSa_rep/frontend/cckappa_sig.mli index 4dfde714b..4333cfa7b 100644 --- a/core/KaSa_rep/frontend/cckappa_sig.mli +++ b/core/KaSa_rep/frontend/cckappa_sig.mli @@ -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 } diff --git a/core/KaSa_rep/frontend/list_tokens.ml b/core/KaSa_rep/frontend/list_tokens.ml index 36942e10e..435f9beb7 100644 --- a/core/KaSa_rep/frontend/list_tokens.ml +++ b/core/KaSa_rep/frontend/list_tokens.ml @@ -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 = @@ -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 ( @@ -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) = diff --git a/core/grammar/ast.mli b/core/grammar/ast.mli index cfa18d37d..821decd01 100644 --- a/core/grammar/ast.mli +++ b/core/grammar/ast.mli @@ -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 ->