aboutsummaryrefslogtreecommitdiffstats
path: root/lib/scl
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-06-23 23:53:26 -0300
committerGitHub <noreply@github.com>2026-06-23 23:53:26 -0300
commitc284fcd570342c31bc21169960579a20a763e32e (patch)
treece7485055116d794c55090ad0978e0b3f5ff4c2a /lib/scl
parentb81586ee4a0543a5f9866586c78dccdd6328934a (diff)
downloadSakura-c284fcd570342c31bc21169960579a20a763e32e.tar.gz
Sakura-c284fcd570342c31bc21169960579a20a763e32e.zip
Format
Diffstat (limited to '')
-rw-r--r--lib/scl/ast.ml6
-rw-r--r--lib/scl/executor.ml18
-rw-r--r--lib/scl/parser.ml4
-rw-r--r--lib/scl/sublanguage.ml7
4 files changed, 13 insertions, 22 deletions
diff --git a/lib/scl/ast.ml b/lib/scl/ast.ml
index 043f544..41a5239 100644
--- a/lib/scl/ast.ml
+++ b/lib/scl/ast.ml
@@ -1,7 +1,7 @@
open Sexplib.Std
type statement =
- | Begin of { query : Drl.Ast.query; limit : int option }
- | Fetch of { cursor : string; limit : int option }
- | Close of { cursor : string }
+ | Begin of {query: Drl.Ast.query; limit: int option}
+ | Fetch of {cursor: string; limit: int option}
+ | Close of {cursor: string}
[@@deriving sexp]
diff --git a/lib/scl/executor.ml b/lib/scl/executor.ml
index e40fde6..5fadc6d 100644
--- a/lib/scl/executor.ml
+++ b/lib/scl/executor.ml
@@ -1,20 +1,14 @@
let default_batch = 50
-type cursor_batch = {
- cursor_id : string;
- rows : Tuple.materialized list;
- has_more : bool;
-}
-
-type exec_result =
- | Batch of cursor_batch
- | Closed of Sublanguage_types.transition_delta
+type cursor_batch = {cursor_id: string; rows: Tuple.materialized list; has_more: bool}
+type exec_result = Batch of cursor_batch | Closed of Sublanguage_types.transition_delta
module Make (NT : Nt.S) = struct
module DrlExec = Drl.Executor.Make (NT)
module Error = struct
open Condition
+
(* TODO: more structure *)
let cursor_error msg = condition "cursor-error" msg empty
end
@@ -25,10 +19,8 @@ module Make (NT : Nt.S) = struct
(exec_result, Condition.t) result =
ignore default_batch;
match stmt with
- | Ast.Begin _ ->
- Error (Error.cursor_error "cursors not yet implemented")
- | Ast.Fetch _ ->
- Error (Error.cursor_error "cursors not yet implemented")
+ | Ast.Begin _ -> Error (Error.cursor_error "cursors not yet implemented")
+ | Ast.Fetch _ -> Error (Error.cursor_error "cursors not yet implemented")
| Ast.Close _ ->
let* () = Ok () in
Ok (Closed ctx.branch#multigroups)
diff --git a/lib/scl/parser.ml b/lib/scl/parser.ml
index 53719ee..670139b 100644
--- a/lib/scl/parser.ml
+++ b/lib/scl/parser.ml
@@ -1,11 +1,11 @@
module Error = struct
open Condition
+
let parse_error msg = condition "parse-error" msg empty
end
let validate = function
- | (Ast.Begin { limit = Some limit; _ } | Ast.Fetch { limit = Some limit; _ })
- when limit <= 0 ->
+ | (Ast.Begin {limit= Some limit; _} | Ast.Fetch {limit= Some limit; _}) when limit <= 0 ->
Error (Error.parse_error "The provision of `limit` is expected to be positive.")
| stmt -> Ok stmt
diff --git a/lib/scl/sublanguage.ml b/lib/scl/sublanguage.ml
index 0793211..526e7a2 100644
--- a/lib/scl/sublanguage.ml
+++ b/lib/scl/sublanguage.ml
@@ -6,13 +6,12 @@ module Make (NT : Nt.S) = struct
let name = "scl"
let parse _ = Ok ()
-
let parse_sexp sexp = Parser.of_sexp sexp
let execute ctx ast =
Exec.execute ctx ast
|> Result.map (function
- | Executor.Batch { cursor_id; rows; has_more } ->
- Sublanguage_types.Cursor { cursor_id; rows; has_more }
- | Executor.Closed delta -> Sublanguage_types.Transition delta)
+ | Executor.Batch {cursor_id; rows; has_more} ->
+ Sublanguage_types.Cursor {cursor_id; rows; has_more}
+ | Executor.Closed delta -> Sublanguage_types.Transition delta )
end