-
Notifications
You must be signed in to change notification settings - Fork 37
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
[0067-feel-split-function] The regex usage differences from the DMN specification #676
Comments
This looks to me like a spec issue. There is no need for a double backslash since |
👍 For adding the example in the spec and the TCK.
Are you sure? I'm a bit confused about how the escape sequences and regex characters should be handled in FEEL. Let's look at the following examples:
In JavaScript, the example looks a bit different. "John\nDoe".split(new RegExp("\\n"));
"John Doe".split(new RegExp("\\s"));
// or, with literal notation
"John\nDoe".split(/\n/);
"John Doe".split(/\s/); It looks similar in Java: "John\nDoe".split("\\n")
// "\s" produces a compile failure
"John Doe".split("\\s") |
I think we should stick to what the specification states as it conforms to both Java and JavaScript standards. I don't see a reason why FEEL should deviate from the de-facto standard of the programming languages. |
The question to discuss here is if Cf. JavaScript example, again, a raw |
Based on the discussion on the meeting:
"pattern, replacement, and flags SHALL conform to the syntax and constraints specified in So the format should depend on the XQuery and XPath syntax and needs to be checked there, if the current form is correct in the spec, or in the test. |
According to the XML spec for regular expressions https://www.w3.org/TR/xmlschema-2/#regexs
is the correct syntax. |
I'm sorry but I cannot follow that line of thought. What is the type of
If
The spec refers to the literal value of a string, not the representation, hence this quote is not relevant to the discussion. Whatever string representation yields the literal value of |
I think that based on
The lexeme is different but the value is the same. The split() call uses the value, not the lexeme. I suggest adding a test for "\s" as well. |
@opatrascoiu This partly answeres my question:
I hope we end up in a simpler solution:
I think this is where I disagree. Intuitively, from the user perspective what looks like a
|
To understand the semantics of strings and regular expressions we need to read the DMN / FEEL carefully. AFAIK these are covered as follows
According to the 10.3.2.3 Semantics of literals and datatypes, the string lexemes are evaluated and produce values in the semantic domain (e.g. escaped sequences are replaced with the value of the character). This value is used to evaluate other constructions (e.g. function calls). For example, if the value of the string passed to split() is not a valid XML regular expression, the evaluator reports an error. This is true both for FEEL and other languages (e.g. escape sequences in Java). According to
If order to be invalid, rule 33 should look like that
If there is another section that states that "" is an invalid string, please let me know. Feel free to raise an RTF issue about marking |
This clears this discussion for me. Thanks for taking your time to elaborate. |
Description
The test case 0067-feel-split-function: 001 verifies the usage of the
split()
function with a regex argument.The DMN evaluates the following FEEL expression:
The test case is the same as in the DMN 1.5 specification (Chapter 10.3.4.3 String functions, page 142):
However, there is a difference in the regex. Instead of
"\\s"
from the DMN specification, the test case uses"\s"
(one backslash vs. two backslash).We should align the TCK test case with the DMN specification.
As far as I understand the DMN specification, the string literal
"\s"
is invalid because it is not a listed escape character (from grammar rule 64):The text was updated successfully, but these errors were encountered: