Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.16] fix: Variable name starting with "in" #912

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/main/scala/org/camunda/feel/impl/parser/FeelParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,17 @@ object FeelParser {
// an identifier which is not a reserved word. but, it can contain a reserved word.
private def identifier[_: P]: P[String] =
P(
reservedWord.? ~~ javaLikeIdentifier
(reservedWord ~~ namePart) | (reservedWord.? ~~ nameStart ~~ namePart.?)
).!

private def javaLikeIdentifier[_: P]: P[String] =
private def nameStart[_: P]: P[String] =
P(
CharPred(Character.isJavaIdentifierStart) ~~ CharsWhile(Character.isJavaIdentifierPart, 0)
CharPred(Character.isJavaIdentifierStart)
).!

private def namePart[_: P]: P[String] =
P(
CharsWhile(Character.isJavaIdentifierPart, 1)
).!

// an identifier wrapped in backticks. it can contain any char (e.g. `a b`, `a+b`).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ class InterpreterExpressionTest
"inside",
"durationX",
"dateX",
"timeX"
"timeX",
"inX",
"in1"
).foreach { variableName =>
it should s"contain a key-word ($variableName)" in {

Expand Down
Loading