Skip to content

Commit

Permalink
fix(engine): add return, then, else as reserved keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
tasso94 committed Jan 27, 2022
1 parent d538afe commit 133ca16
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ A clear and concise description of what you expected to happen.
**Environment**
* FEEL engine version: [1.x.y]
* Affects:
* Camunda BPM: [7.x] <!-- link the issue: https://jira.camunda.com/browse/CAM- -->
* Camunda Automation Platform 7: [7.x] <!-- link the issue: https://jira.camunda.com/browse/CAM- -->
* Zeebe broker: [0.x] <!-- link the issue: https://github.com/zeebe-io/zeebe/issues# -->
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ A clear and concise description of what you want to happen.

**Related issues**

* Camunda BPM: <!-- link the issue: https://jira.camunda.com/browse/CAM- -->
* Camunda Autormation Platform 7: <!-- link the issue: https://jira.camunda.com/browse/CAM- -->
* Zeebe broker: <!-- link the issue: https://github.com/zeebe-io/zeebe/issues# -->
9 changes: 5 additions & 4 deletions src/main/scala/org/camunda/feel/impl/parser/FeelParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ object FeelParser {
"true",
"false",
"function",
"in"
"in",
"return",
"then",
"else"
)
).!

Expand Down Expand Up @@ -437,9 +440,7 @@ object FeelParser {
).!

private def variableRef[_: P]: P[Exp] =
P(
qualifiedName
).map(Ref(_))
P((identifier.! | escapedIdentifier) ~ !"(").map(n => Ref(List(n)))

private def inputValue[_: P]: P[Exp] =
P(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ class InterpreterExpressionTest
eval("if 1 instance of number then 1 else 2") should be(ValNumber(1))
}

it should "be an if-then-else (with variable and function call -> then)" in {
eval("if 7 > var then flatten(xs) else []",
Map("xs" -> List(1, 2), "var" -> 3)) should be(
ValList(List(ValNumber(1), ValNumber(2)))
)
}

it should "be an if-then-else (with variable and function call -> else)" in {
eval("if false then var else flatten(xs)",
Map("xs" -> List(1, 2), "var" -> 3)) should be(
ValList(List(ValNumber(1), ValNumber(2)))
)
}

it should "be a simple positive unary test" in {

eval("< 3", Map(UnaryTests.defaultInputVariable -> 2)) should be(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class InterpreterListExpressionTest

eval("for x in xs return x * 2", Map("xs" -> List(1, 2))) should be(
ValList(List(ValNumber(2), ValNumber(4))))

eval("for y in xs return index of([2, 3], y)", Map("xs" -> List(1, 2))) should be(
ValList(List(ValList(List()), ValList(List(ValNumber(1)))))
)
}

it should "be processed in a for-expression (range)" in {
Expand Down

0 comments on commit 133ca16

Please sign in to comment.