mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-20 01:10:44 +00:00
Implement ARRAY_CONCAT, ARRAY_LENGTH, ARRAY_SLICE, SetIntersect, SetUnion functions
This commit is contained in:
@@ -312,19 +312,9 @@ BooleanLiteral <- ("true"i / "false"i) {
|
||||
|
||||
FunctionCall <- StringFunctions
|
||||
/ TypeCheckingFunctions
|
||||
/ ArrayFunctions
|
||||
/ InFunction
|
||||
|
||||
TypeCheckingFunctions <- IsDefined
|
||||
/ IsArray
|
||||
/ IsBool
|
||||
/ IsFiniteNumber
|
||||
/ IsInteger
|
||||
/ IsNull
|
||||
/ IsNumber
|
||||
/ IsObject
|
||||
/ IsPrimitive
|
||||
/ IsString
|
||||
|
||||
StringFunctions <- StringEqualsExpression
|
||||
/ ToStringExpression
|
||||
/ ConcatExpression
|
||||
@@ -342,6 +332,23 @@ StringFunctions <- StringEqualsExpression
|
||||
/ SubstringExpression
|
||||
/ TrimExpression
|
||||
|
||||
TypeCheckingFunctions <- IsDefined
|
||||
/ IsArray
|
||||
/ IsBool
|
||||
/ IsFiniteNumber
|
||||
/ IsInteger
|
||||
/ IsNull
|
||||
/ IsNumber
|
||||
/ IsObject
|
||||
/ IsPrimitive
|
||||
/ IsString
|
||||
|
||||
ArrayFunctions <- ArrayConcatExpression
|
||||
/ ArrayLengthExpression
|
||||
/ ArraySliceExpression
|
||||
/ SetIntersectExpression
|
||||
/ SetUnionExpression
|
||||
|
||||
UpperExpression <- "UPPER"i ws "(" ex:SelectItem ")" {
|
||||
return createFunctionCall(parsers.FunctionCallUpper, []interface{}{ex})
|
||||
}
|
||||
@@ -465,6 +472,26 @@ IsString <- "IS_STRING"i ws "(" ws ex:SelectItem ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallIsString, []interface{}{ex})
|
||||
}
|
||||
|
||||
ArrayConcatExpression <- "ARRAY_CONCAT"i ws "(" ws arrays:SelectItem others:(ws "," ws ex:SelectItem { return ex, nil })+ ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallArrayConcat, append([]interface{}{arrays}, others.([]interface{})...))
|
||||
}
|
||||
|
||||
ArrayLengthExpression <- "ARRAY_LENGTH"i ws "(" ws array:SelectItem ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallArrayLength, []interface{}{array})
|
||||
}
|
||||
|
||||
ArraySliceExpression <- "ARRAY_SLICE"i ws "(" ws array:SelectItem ws "," ws start:SelectItem length:(ws "," ws ex:SelectItem { return ex, nil })? ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallArraySlice, []interface{}{array, start, length})
|
||||
}
|
||||
|
||||
SetIntersectExpression <- "SetIntersect"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallSetIntersect, []interface{}{set1, set2})
|
||||
}
|
||||
|
||||
SetUnionExpression <- "SetUnion"i ws "(" ws set1:SelectItem ws "," ws set2:SelectItem ws ")" {
|
||||
return createFunctionCall(parsers.FunctionCallSetUnion, []interface{}{set1, set2})
|
||||
}
|
||||
|
||||
InFunction <- ex1:SelectProperty ws "IN"i ws "(" ws ex2:SelectItem others:(ws "," ws ex:SelectItem { return ex, nil })* ws ")" {
|
||||
arguments := append([]interface{}{ex1, ex2}, others.([]interface{})...)
|
||||
return parsers.FunctionCall{Type: parsers.FunctionCallIn, Arguments: arguments}, nil
|
||||
|
||||
Reference in New Issue
Block a user