diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-26 15:30:53 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-26 15:30:53 -0300 |
| commit | e32ba6294781691846c3ab19281fe977350b4d0f (patch) | |
| tree | f38e92ba2fc03e966d7263c7ee2e0b5d7983ebae /lib/icl | |
| parent | be375a52da6174dfda5b68617d27e1542cc80499 (diff) | |
| download | Sakura-e32ba6294781691846c3ab19281fe977350b4d0f.tar.gz Sakura-e32ba6294781691846c3ab19281fe977350b4d0f.zip | |
preparation cleanup for RNT integration
Diffstat (limited to 'lib/icl')
| -rw-r--r-- | lib/icl/ast.ml | 17 | ||||
| -rw-r--r-- | lib/icl/executor.ml | 53 | ||||
| -rw-r--r-- | lib/icl/parser.ml | 17 | ||||
| -rw-r--r-- | lib/icl/sublanguage.ml | 15 |
4 files changed, 0 insertions, 102 deletions
diff --git a/lib/icl/ast.ml b/lib/icl/ast.ml deleted file mode 100644 index 1a5b096..0000000 --- a/lib/icl/ast.ml +++ /dev/null @@ -1,17 +0,0 @@ -open Sexplib.Std - -type binding_expr = Var of string | Const of Drl.Ast.value (** reuse DRL value for literals *) -[@@deriving sexp] - -type constraint_body = - | MemberOf of {target: string; binding: (string * binding_expr) list} - | Not of {body: constraint_body; universe: string} - | And of constraint_body list - | Or of constraint_body list - | Exists of {variable: string; quantifier: string; body: constraint_body} - | Forall of {variable: string; quantifier: string; body: constraint_body} -[@@deriving sexp] - -type statement = - | RegisterConstraint of {constraint_name: string; relation_name: string; body: constraint_body} -[@@deriving sexp] diff --git a/lib/icl/executor.ml b/lib/icl/executor.ml deleted file mode 100644 index dd0a1d9..0000000 --- a/lib/icl/executor.ml +++ /dev/null @@ -1,53 +0,0 @@ -module Make (NT : Nt.S) = struct - module Error = struct - open Condition - - let multigroup_not_found name = - condition "multigroup-not-found" "Multigroup not found" ("name" |=| of_string name) - end - - let ( let* ) = Result.bind - let parse_fqn (s : string) : (Qualified_name.t, Condition.t) result = Qualified_name.try_parse s - - let lookup_mg (ctx : Sublanguage_context.t) (mg_name : string) : - (Management.Multigroup.multigroup, Condition.t) result = - match ctx.branch#mg_of mg_name with - | Some mg -> Ok mg - | None -> Error (Error.multigroup_not_found mg_name) - - let convert_binding_expr : Ast.binding_expr -> Constraint.binding_expr = function - | Ast.Var name -> Constraint.Var name - | Ast.Const value -> Constraint.Const (Drl.Ast.value_to_abstract value) - - let convert_binding (pairs : (string * Ast.binding_expr) list) : Constraint.binding = - List.fold_left - (fun acc (key, expr) -> Constraint.BindingMap.add key (convert_binding_expr expr) acc) - Constraint.BindingMap.empty pairs - - let rec convert_body : Ast.constraint_body -> Constraint.t = function - | Ast.MemberOf {target; binding} -> - Constraint.member_of ~target ~binding:(convert_binding binding) - | Ast.Not {body; universe} -> Constraint.not_ ~universe (convert_body body) - | Ast.And bodies -> Constraint.and_ (List.map convert_body bodies) - | Ast.Or bodies -> Constraint.or_ (List.map convert_body bodies) - | Ast.Exists {variable; quantifier; body} -> - Constraint.exists ~variable ~quantifier (convert_body body) - | Ast.Forall {variable; quantifier; body} -> - Constraint.forall ~variable ~quantifier (convert_body body) - - let execute (ctx : Sublanguage_context.t) (stmt : Ast.statement) : - (Sublanguage_types.transition_delta * string, Condition.t) result = - match stmt with - | Ast.RegisterConstraint {constraint_name; relation_name; body} -> - let* fqn = parse_fqn relation_name in - let* mg = lookup_mg ctx fqn.mg in - let runtime_body = convert_body body in - let* _bh, new_mg = - NT.register_constraint ctx.write_handle mg ~constraint_name ~relation_name:fqn.name - ~body:runtime_body - in - ctx.branch#set_mg ~name:fqn.mg new_mg; - Ok ([fqn.mg, new_mg], "Constraint registered: " ^ constraint_name) -end - -module Memory = Make (Nt.Memory) diff --git a/lib/icl/parser.ml b/lib/icl/parser.ml deleted file mode 100644 index 094b0fd..0000000 --- a/lib/icl/parser.ml +++ /dev/null @@ -1,17 +0,0 @@ -module Error = struct - open Condition - - let parse_error msg = condition "parse-error" msg empty -end - -let of_sexp sexp = - match Ast.statement_of_sexp sexp with - | stmt -> Ok stmt - | exception exn -> Error (Error.parse_error (Printexc.to_string exn)) - -let of_string s = - match Sexplib.Sexp.of_string s |> Ast.statement_of_sexp with - | stmt -> Ok stmt - | exception exn -> Error (Error.parse_error (Printexc.to_string exn)) - -let to_string stmt = Ast.sexp_of_statement stmt |> Sexplib.Sexp.to_string_hum diff --git a/lib/icl/sublanguage.ml b/lib/icl/sublanguage.ml deleted file mode 100644 index c68077d..0000000 --- a/lib/icl/sublanguage.ml +++ /dev/null @@ -1,15 +0,0 @@ -module Make (NT : Nt.S) = struct - module Exec = Executor.Make (NT) - - type configuration = unit - type ast = Ast.statement - - let name = "icl" - let parse _ = Ok () - let parse_sexp sexp = Parser.of_sexp sexp - - let execute ctx ast = - match Exec.execute ctx ast with - | Ok (delta, _msg) -> Ok (Sublanguage_types.Transition delta) - | Error e -> Error e -end |
