diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-05-30 01:43:10 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-30 01:43:10 +0000 |
| commit | 8106d31690dad61ee0ec649ae6de7f4e3fe1830e (patch) | |
| tree | fc50ca3bdf755cee7157540b79ba26d6ecef7e62 /lib/sublanguage_context.ml | |
| parent | 1378202e6b0b51d7d338a1042824860f19fcbc9b (diff) | |
| download | Sakura-8106d31690dad61ee0ec649ae6de7f4e3fe1830e.tar.gz Sakura-8106d31690dad61ee0ec649ae6de7f4e3fe1830e.zip | |
Some scaffolding for sublanguage tests (#72)
* No need to take the multigroup name as an argument
* Record backtraces when instantiating conditions
* Equality for abstract values
* Move `make_ctx` out of the listener
* Include the return code on `handle-error` conditions
* Do not include brackets around stringified condition properties
* Equality for materialized attributes
* Equality for materialized tuples
* Scaffolding for a test suite
Diffstat (limited to 'lib/sublanguage_context.ml')
| -rw-r--r-- | lib/sublanguage_context.ml | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/sublanguage_context.ml b/lib/sublanguage_context.ml index aca5790..39e6dd3 100644 --- a/lib/sublanguage_context.ml +++ b/lib/sublanguage_context.ml @@ -37,3 +37,34 @@ type t = { switch_branch : string -> (Sublanguage_types.transition_delta, Condition.t) result; } + +module Make (NT : Nt.S) = struct + module Session = Session.Make (NT) + module Branch = Branch.Make (NT) + + let make_ctx + (session : Session.session) + (claims : string) + : t = + let br = session#branch in + { + write_handle = br#branch_handle; + branch = (br :> branch_view); + resolve = br#path; + switch_branch = fun name -> + match br#close () with + | Error e -> Error e + | Ok () -> + begin match Branch.open_branch claims name with + | Error e -> + begin match Branch.open_branch claims "master" with + | Ok mbr -> session#set_branch mbr + | Error _ -> () + end; + Error e + | Ok new_br -> + session#set_branch new_br; + Ok new_br#multigroups + end + } +end |
