diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-05-21 01:19:40 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-05-21 01:19:40 +0000 |
| commit | 4161e4e8328d2d104c028bd1987cd6950aab97e0 (patch) | |
| tree | 7684e4343899aa082ba0e08cfbb9d1d4ed7ada01 /lib/prl | |
| parent | fe0ee9136886ae944b76166d262bf93a34807546 (diff) | |
| download | Sakura-4161e4e8328d2d104c028bd1987cd6950aab97e0.tar.gz Sakura-4161e4e8328d2d104c028bd1987cd6950aab97e0.zip | |
Migrate the PRL over
Diffstat (limited to '')
| -rw-r--r-- | lib/prl/executor.ml | 34 | ||||
| -rw-r--r-- | lib/prl/sublanguage.ml | 7 |
2 files changed, 14 insertions, 27 deletions
diff --git a/lib/prl/executor.ml b/lib/prl/executor.ml index 0ccaf22..8ed4195 100644 --- a/lib/prl/executor.ml +++ b/lib/prl/executor.ml @@ -1,22 +1,14 @@ module Make (NT : Nt.S) = struct - type error = - | ParseError of string - | RuntimeError of string - | NtError of Nt.error - | UnknownPluginSymbol of string - | RelationNotFound of string - - let sexp_of_error e = - let open Sexplib.Sexp in - match e with - | ParseError s -> List [ Atom "parse-error"; Atom s ] - | RuntimeError s -> List [ Atom "runtime-error"; Atom s ] - | NtError e -> List [ Atom "nt-error"; Atom (Nt.string_of_error e) ] - | UnknownPluginSymbol s -> List [ Atom "unknown-plugin-symbol"; Atom s ] - | RelationNotFound s -> List [ Atom "relation-not-found"; Atom s ] + module Error = struct + open Condition + (* TODO: more structure *) + let parse_error msg = condition "parse-error" ("message" |=| (of_string msg)) + let runtime_error msg = condition "runtime-error" ("message" |=| (of_string msg)) + let unknown_plugin_symbol name = condition "unknown-plugin-symbol" ("name" |=| (of_string name)) + let relation_not_found name = condition "relation-not-found" ("name" |=| (of_string name)) + end let ( let* ) = Result.bind - let _map_nt r = Result.map_error (fun e -> NtError e) r (* TODO: PRL function predicates are OCaml shared-library callbacks that produce tuples at runtime. To make their output joinable inside the @@ -26,17 +18,17 @@ module Make (NT : Nt.S) = struct yet exist. Disable PRL execution until that bridge is in place. *) let execute (_ctx : Sublanguage_context.t) (_stmt : Ast.statement) : - (Sublanguage_types.result, error) result = - Error (RuntimeError + (Sublanguage_types.result, Condition.t) result = + Error (Error.runtime_error "PRL execution is temporarily disabled pending VM callback-cursor support") let _execute_load_library _ctx _path = - Error (RuntimeError "PRL disabled") + Error (Error.runtime_error "PRL disabled") let _execute_define_function_predicate _ctx (_spec : Ast.function_predicate) = let* _ = Ok () in - Error (RuntimeError "PRL disabled") + Error (Error.runtime_error "PRL disabled") let _execute_list_function_predicates _ctx = - Error (RuntimeError "PRL disabled") + Error (Error.runtime_error "PRL disabled") end diff --git a/lib/prl/sublanguage.ml b/lib/prl/sublanguage.ml index 96891a9..387da34 100644 --- a/lib/prl/sublanguage.ml +++ b/lib/prl/sublanguage.ml @@ -3,16 +3,11 @@ module Make (NT : Nt.S) = struct type configuration = unit type ast = Ast.statement - type error = Exec.error let name = "prl" let parse _ = Ok () - let parse_sexp sexp = - match Parser.of_sexp sexp with - | Ok r -> Ok r - | Error (Parser.ParseError s) -> Error (Exec.ParseError s) + let parse_sexp sexp = Parser.of_sexp sexp let execute = Exec.execute - let sexp_of_error = Exec.sexp_of_error end |
