diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-26 23:01:54 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-09-26 23:01:54 -0300 |
| commit | 54cd9839a08d3fee7e4521541c9381fac3f0d358 (patch) | |
| tree | 7f725bc60b971efcb00d2051dfa0aae5b3c3d515 /lib/dml/executor.ml | |
| parent | bb304cb5fa4a2a36428a61e378aab614f073e0d3 (diff) | |
| download | Sakura-54cd9839a08d3fee7e4521541c9381fac3f0d358.tar.gz Sakura-54cd9839a08d3fee7e4521541c9381fac3f0d358.zip | |
dummy dml for testingrnt-integration
Diffstat (limited to 'lib/dml/executor.ml')
| -rw-r--r-- | lib/dml/executor.ml | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/dml/executor.ml b/lib/dml/executor.ml new file mode 100644 index 0000000..fdc3c9f --- /dev/null +++ b/lib/dml/executor.ml @@ -0,0 +1,24 @@ +open Utilities.Result + +let value_of = function Ast.Str s -> Value.String s | Ast.Int n -> Value.Integer n +let map_of bindings = List.to_seq bindings |> Utilities.StringMap.of_seq + +let execute (ctx : Sublanguage_context.t) statement = + let* {RNT.branch; _} = ctx.session#state in + let relation = Drl.Executor.relation_path ("\\branch\\" ^ branch) in + let* message = + match statement with + | Ast.Define {target; heading; tuples} -> + let* path = relation target in + let tuples = + List.map (fun row -> List.map (fun (a, v) -> a, value_of v) row |> map_of) tuples + in + let* () = RNT.create ctx.kernel path (RNT.Relation {heading= map_of heading; tuples}) in + Ok ("Defined " ^ target) + | Ast.Drop {target} -> + let* path = relation target in + let* () = RNT.remove ctx.kernel path in + Ok ("Dropped " ^ target) + in + let* () = ctx.session#set_branch_to branch in + Ok (Sublanguage_types.Transition message) |
