diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2024-12-26 21:29:46 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2024-12-26 21:29:46 +0100 |
commit | 6883d69e0f8eb0e67928ad2cfc92bf0792f948c9 (patch) | |
tree | bb3bf5c8b4237a7d08f3b3625d2f18b47733a768 /lib | |
parent | d9022188b6391728a4112b3e632744fb3a548569 (diff) |
Removed some code from the parser and moved it into the Expression.T module
Diffstat (limited to 'lib')
-rw-r--r-- | lib/configuration/expression_parser.mly | 23 | ||||
-rw-r--r-- | lib/expression/t.ml | 10 | ||||
-rw-r--r-- | lib/expression/t.mli | 1 |
3 files changed, 12 insertions, 22 deletions
diff --git a/lib/configuration/expression_parser.mly b/lib/configuration/expression_parser.mly index 54f3bfe..18b79c8 100644 --- a/lib/configuration/expression_parser.mly +++ b/lib/configuration/expression_parser.mly @@ -22,27 +22,6 @@ %right INEQUALITY_OPERATOR EQUALITY_OPERATOR %right CONCAT_OPERATOR BINARY_OPERATOR -%{ - - let function_of_name param f = - match (String.lowercase_ascii f, param) with - | "nvl", _ -> - ImportExpression.T.Nvl param - | "join", (ImportExpression.T.Literal sep:: tl) -> - ImportExpression.T.Join (sep, tl) - | "join", (ImportExpression.T.Empty:: tl) -> - ImportExpression.T.Join ("", tl) - | "upper", _ -> - ImportExpression.T.Function' (ImportExpression.T.Upper, param) - | "trim", _ -> - ImportExpression.T.Function' (ImportExpression.T.Trim, param) - | "cmp", _ -> - ImportExpression.T.Function' (ImportExpression.T.Cmp, param) - | other, _ -> - ImportExpression.T.Function (other, param) - -%} - %% path_expr: @@ -146,7 +125,7 @@ expr_(PATH, ENDING_PHANTOM): { f } | s = IDENT args = arguments(PATH) - { function_of_name args s } + { ImportExpression.T.function_of_name args s } | s = IDENT L_PAREN 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 |