From 986bcb796d8b9e1f485baa8da599aa816c56b587 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Tue, 7 Jan 2025 22:40:19 +0100 Subject: Explicitly list all the availables functions --- lib/expression/t.ml | 21 ++++++++++++++++++--- lib/expression/t.mli | 2 ++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'lib/expression') diff --git a/lib/expression/t.ml b/lib/expression/t.ml index 80cff4f..9ce21b8 100644 --- a/lib/expression/t.ml +++ b/lib/expression/t.ml @@ -38,12 +38,13 @@ and funct = | Trim | Upper -let name_of_function = function +let name_of_function : funct -> string = function | Upper -> "UPPER" | Trim -> "TRIM" | Cmp -> "CMP" -let function_of_name param f = +let function_of_name : 'a t list -> string -> 'a t = + fun param f -> match (String.lowercase_ascii f, param) with | "nvl", _ -> Nvl param | "join", Literal sep :: tl -> Join (sep, tl) @@ -51,7 +52,21 @@ let function_of_name param f = | "upper", _ -> Function' (Upper, param) | "trim", _ -> Function' (Trim, param) | "cmp", _ -> Function' (Cmp, param) - | other, _ -> Function (other, param) + (* Branch function *) + | ("if" as fn), [ _; _; _ ] -> Function (fn, param) + (* Integer functions *) + | ("abs" as fn), _ + | ("int" as fn), _ + (* String functions *) + | ("concat" as fn), _ + | ("match" as fn), _ + | ("substring" as fn), _ + (* Date functions *) + | ("date" as fn), _ + | ("year" as fn), _ -> Function (fn, param) + | _ -> + (*Function (other, param)*) + raise (ImportErrors.UnknowFunction f) let name_of_operator = function | Equal -> "=" diff --git a/lib/expression/t.mli b/lib/expression/t.mli index 4b13ac6..49ef3e7 100644 --- a/lib/expression/t.mli +++ b/lib/expression/t.mli @@ -53,4 +53,6 @@ val name_of_window : 'a window -> string val map_window : f:('a -> 'b) -> 'a window -> 'b window val window_of_name : string -> 'a option -> 'a window val name_of_function : funct -> string + val function_of_name : 'a t list -> string -> 'a t +(** Create a function with the given name *) -- cgit v1.2.3