diff options
Diffstat (limited to 'lib/prl')
| -rw-r--r-- | lib/prl/executor.ml | 34 | ||||
| -rw-r--r-- | lib/prl/parser.ml | 7 | ||||
| -rw-r--r-- | lib/prl/sublanguage.ml | 7 |
3 files changed, 19 insertions, 29 deletions
diff --git a/lib/prl/executor.ml b/lib/prl/executor.ml index 0ccaf22..fcd4ec0 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" msg empty + let runtime_error msg = condition "runtime-error" msg empty + let unknown_plugin_symbol name = condition "unknown-plugin-symbol" "Unknown plugin" ("name" |=| (of_string name)) + let relation_not_found name = condition "relation-not-found" "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/parser.ml b/lib/prl/parser.ml index 17102a4..2567eea 100644 --- a/lib/prl/parser.ml +++ b/lib/prl/parser.ml @@ -1,4 +1,7 @@ -type error = ParseError of string +module Error = struct + open Condition + let parse_error msg = condition "parse-error" msg empty +end let of_sexp sexp = let sexp = @@ -6,7 +9,7 @@ let of_sexp sexp = in match Ast.statement_of_sexp sexp with | stmt -> Ok stmt - | exception exn -> Error (ParseError (Printexc.to_string exn)) + | exception exn -> Error (Error.parse_error (Printexc.to_string exn)) let of_string s = of_sexp (Sexplib.Sexp.of_string s) let to_string stmt = Ast.sexp_of_statement stmt |> Sexplib.Sexp.to_string_hum 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 |
