File tree 2 files changed +25
-2
lines changed
main/scala/org/camunda/feel/impl/parser
test/scala/org/camunda/feel/impl/interpreter
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,9 @@ object FeelParser {
147
147
" return" ,
148
148
" then" ,
149
149
" else" ,
150
- " satisfies"
150
+ " satisfies" ,
151
+ " and" ,
152
+ " or"
151
153
)
152
154
).!
153
155
@@ -490,7 +492,7 @@ object FeelParser {
490
492
491
493
private def functionInvocation [_ : P ]: P [Exp ] =
492
494
P (
493
- (identifierWithWhitespaces
495
+ (( identifierWithWhitespaces | functionNameWithReservedWord)
494
496
.map(List (_)) | qualifiedName) ~ " (" ~ functionParameters.? ~ " )"
495
497
).map {
496
498
case (name :: Nil , None ) =>
@@ -507,6 +509,13 @@ object FeelParser {
507
509
parameters)
508
510
}
509
511
512
+ // List all built-in function names that contains a reserved word. These names are not allowed as
513
+ // regular function names.
514
+ private def functionNameWithReservedWord [_ : P ]: P [String ] =
515
+ P (
516
+ " and" | " or" | " date and time" | " years and months duration"
517
+ ).!
518
+
510
519
private def functionParameters [_ : P ]: P [FunctionParameters ] =
511
520
namedParameters | positionalParameters
512
521
Original file line number Diff line number Diff line change @@ -75,6 +75,14 @@ class InterpreterBooleanExpressionTest
75
75
ValBoolean (true ))
76
76
}
77
77
78
+ it should " be in conjunction (with parentheses)" in {
79
+ eval(" x and (y)" , Map (" x" -> true , " y" -> false )) should be(
80
+ ValBoolean (false ))
81
+
82
+ eval(" (x) and y" , Map (" x" -> true , " y" -> false )) should be(
83
+ ValBoolean (false ))
84
+ }
85
+
78
86
it should " be in disjunction" in {
79
87
80
88
eval(" false or true" ) should be(ValBoolean (true ))
@@ -91,6 +99,12 @@ class InterpreterBooleanExpressionTest
91
99
eval(" 2 or 4" ) should be(ValNull )
92
100
}
93
101
102
+ it should " be in disjunction (with parentheses)" in {
103
+ eval(" x or (y)" , Map (" x" -> false , " y" -> true )) should be(ValBoolean (true ))
104
+
105
+ eval(" (x) or y" , Map (" x" -> false , " y" -> true )) should be(ValBoolean (true ))
106
+ }
107
+
94
108
it should " be in disjunction with comparison" in {
95
109
eval(" 1 = 1 or 1 = 2" ) should be(ValBoolean (true ))
96
110
}
You can’t perform that action at this time.
0 commit comments