From 6b377719c10d5ab3343fd5221f99a4a21008e25a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 14 Mar 2024 08:26:58 +0100 Subject: Initial commit --- lib/expression/ast.ml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/expression/ast.ml (limited to 'lib/expression/ast.ml') diff --git a/lib/expression/ast.ml b/lib/expression/ast.ml new file mode 100644 index 0000000..ef083e9 --- /dev/null +++ b/lib/expression/ast.ml @@ -0,0 +1,31 @@ +(** This module rebuilds an AST from an evaluation *) + +type 'a repr = 'a T.t +type 'a obs = 'a T.t +type 'a path_repr = unit + +let observe : 'a repr -> 'a obs = Fun.id +let empty : unit -> 'a repr = fun () -> T.Empty +let expr : 'a repr -> 'a repr = fun t -> T.Expr t +let literal : string -> 'a repr = fun s -> T.Literal s +let integer : string -> 'a repr = fun i -> T.Integer i +let path : 'a path_repr -> 'a -> 'a repr = fun _repr p -> T.Path p +let concat : 'a repr list -> 'a repr = fun ll -> T.Concat ll + +let window : 'a repr T.window -> 'a repr list -> 'a repr list -> 'a repr = + fun w groups order -> T.Window (w, groups, order) + +let nvl : 'a repr list -> 'a repr = fun ll -> T.Nvl ll +let join : string -> 'a repr list -> 'a repr = fun s ll -> T.Join (s, ll) + +let boperator : T.binary_operator -> 'a repr -> 'a repr -> 'a repr = + fun op e1 e2 -> T.BOperator (op, e1, e2) + +let gequality : T.binary_operator -> 'a repr -> 'a repr list -> 'a repr = + fun op e1 ll -> T.GEquality (op, e1, ll) + +let funct : string -> 'a repr list -> 'a repr = + fun name args -> T.Function (name, args) + +let function' : T.funct -> 'a repr list -> 'a repr = + fun f args -> T.Function' (f, args) -- cgit v1.2.3