aboutsummaryrefslogblamecommitdiffstats
path: root/lib/drl/sublanguage.ml
blob: 29047c30b0fc69e8575c6f5cc1018def5f9168ab (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                      
                                       
 
                           
                          

                         

                  
                     








                                                              

                                              
                                                    
                             



                                        
                                                 
module Make (Storage : Management.Physical.S) = struct
  module Exec = Executor.Make (Storage)

  type configuration = unit
  type storage = Storage.t
  type ast = Ast.query
  type error = Exec.error

  let name = "drl"
  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 execute storage db ast =
    match Gate.admit db ast with
    | Error msg -> Error (Exec.ParseError msg)
    | Ok () -> (
        match Exec.execute storage db ast with
        | Ok rel -> Ok (Sublanguage_types.Query rel)
        | Error e -> Error e)

  let sexp_of_error = Exec.sexp_of_error
end

module Memory = Make (Management.Physical.Memory)