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

regex escape sequence support #7741

Open
AStenbaek opened this issue May 17, 2024 · 0 comments
Open

regex escape sequence support #7741

AStenbaek opened this issue May 17, 2024 · 0 comments

Comments

@AStenbaek
Copy link
Contributor

AStenbaek commented May 17, 2024

At the moment regex is checked with the same function as strings.
This results in the compiler rejecting regular expressions that are valid in the Java implementation, the system is based on,
due to some escape sequences being illegal in strings.

As an example, the following program is currently rejected:

def main(): Unit \ IO = Regex.isMatch(regex"\w", "W") |> println

The issues stems from the following code:

case ParsedAst.Literal.Regex(sp1, chars, sp2) =>
visitCharSeq(chars).flatMap {
case s => toRegexPattern(s, mkSL(sp1, sp2)).map {
case pat => Ast.Constant.Regex(pat)
}
}
}

The weeder should be updated to allow escape sequences from: https://docs.oracle.com/en%2Fjava%2Fjavase%2F21%2Fdocs%2Fapi%2F%2F/java.base/java/util/regex/Pattern.html#cg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant