Implement CONTAINS function

This commit is contained in:
Pijus Kamandulis
2024-02-21 20:25:14 +02:00
parent 8ab9680c99
commit 9bf3dc22ed
7 changed files with 365 additions and 107 deletions

View File

@@ -306,7 +306,7 @@ BooleanLiteral <- ("true"i / "false"i) {
return parsers.Constant{Type: parsers.ConstantTypeBoolean, Value: boolValue}, nil
}
FunctionCall <- StringEqualsExpression / ConcatExpression / IsDefined
FunctionCall <- StringEqualsExpression / ConcatExpression / ContainsExpression / IsDefined
StringEqualsExpression <- StringEquals ws "(" ws ex1:SelectItem ws "," ws ex2:SelectItem ws ignoreCase:("," ws boolean:SelectItem { return boolean, nil })? ")" {
return parsers.FunctionCall{Type: parsers.FunctionCallStringEquals, Arguments: []interface{}{ex1, ex2, ignoreCase}}, nil
@@ -317,6 +317,10 @@ ConcatExpression <- "CONCAT"i ws "(" ws ex1:SelectItem others:(ws "," ws ex:Sele
return parsers.FunctionCall{Type: parsers.FunctionCallConcat, Arguments: arguments}, nil
}
ContainsExpression <- "CONTAINS"i ws "(" ws ex1:SelectItem ws "," ws ex2:SelectItem ws ignoreCase:("," ws boolean:SelectItem { return boolean, nil })? ")" {
return parsers.FunctionCall{Type: parsers.FunctionCallContains, Arguments: []interface{}{ex1, ex2, ignoreCase}}, nil
}
IsDefined <- "IS_DEFINED"i ws "(" ws ex:SelectItem ws ")" {
return parsers.FunctionCall{Type: parsers.FunctionCallIsDefined, Arguments: []interface{}{ex}}, nil
}