From 6883d69e0f8eb0e67928ad2cfc92bf0792f948c9 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 26 Dec 2024 21:29:46 +0100 Subject: Removed some code from the parser and moved it into the Expression.T module --- lib/expression/t.ml | 10 ++++++++++ lib/expression/t.mli | 1 + 2 files changed, 11 insertions(+) (limited to 'lib/expression') diff --git a/lib/expression/t.ml b/lib/expression/t.ml index 2df374f..80cff4f 100644 --- a/lib/expression/t.ml +++ b/lib/expression/t.ml @@ -43,6 +43,16 @@ let name_of_function = function | Trim -> "TRIM" | Cmp -> "CMP" +let function_of_name param f = + match (String.lowercase_ascii f, param) with + | "nvl", _ -> Nvl param + | "join", Literal sep :: tl -> Join (sep, tl) + | "join", Empty :: tl -> Join ("", tl) + | "upper", _ -> Function' (Upper, param) + | "trim", _ -> Function' (Trim, param) + | "cmp", _ -> Function' (Cmp, param) + | other, _ -> Function (other, param) + let name_of_operator = function | Equal -> "=" | Different -> "<>" diff --git a/lib/expression/t.mli b/lib/expression/t.mli index 3cd5d23..4b13ac6 100644 --- a/lib/expression/t.mli +++ b/lib/expression/t.mli @@ -53,3 +53,4 @@ 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 -- cgit v1.2.3