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

Improve regular expression error messages #5871

Merged

Conversation

anthony-chang
Copy link
Contributor

Closes #4537

This PR improves the error messages when throwing RegexUnsupportedExceptions by attempting to isolate what exactly in the pattern is not supported. I also added a position field to RegexAST and recorded the index of each node in the AST within the regular expression pattern in the parse stage, so that this can be printed in errors thrown in the rewrite stage. All RegexUnsupportedExceptions must specify the index now.

There should be no changes to functionality.

Signed-off-by: Anthony Chang <antchang@nvidia.com>
…ing regex

Signed-off-by: Anthony Chang <antchang@nvidia.com>
Signed-off-by: Anthony Chang <antchang@nvidia.com>
Signed-off-by: Anthony Chang <antchang@nvidia.com>
Signed-off-by: Anthony Chang <antchang@nvidia.com>
Signed-off-by: Anthony Chang <antchang@nvidia.com>
@anthony-chang anthony-chang self-assigned this Jun 17, 2022
@sameerz sameerz added the task Work required that improves the product but is not user facing label Jun 18, 2022
@anthony-chang anthony-chang changed the title [WIP] Improve regular expression error messages Improve regular expression error messages Jun 21, 2022
@anthony-chang anthony-chang marked this pull request as ready for review June 21, 2022 23:31
…prove-regex-error-messages

Signed-off-by: Anthony Chang <antchang@nvidia.com>
@anthony-chang
Copy link
Contributor Author

build


case (RegexGroup(capture, term), SimpleQuantifier(ch))
if "+*".contains(ch) && !isSupportedRepetitionBase(term) =>
if "+*".contains(ch) && !(isSupportedRepetitionBase(term)._1) =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend converting this to a pattern matching construct to avoid _1, _2 references and the use Option.get().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this in a separate PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Work required that improves the product but is not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA] Improve regexp error messages
4 participants