Add compile-time validation of regular expressions.#2281
Draft
Conversation
d9c35a0 to
23c0565
Compare
These allow to (1) validate a regular expression and (2) determine its number of capture groups. They work by temporarily compiling the patterns. Also includes a tiny cleanup removing an unused function parameter.
23c0565 to
2de6e90
Compare
So far we would catch pattern errors only at runtime. Now we report the following at compile time if it can be statically determined: - Patterns that don't compile (e.g., due to syntax errors) - Use of `$N` referring to a capture group that exceeds the number a pattern defines. - Use of `$N' with a regular expression specifying multiple patterns for parallel matching (in which case group numbers are ill-defined). - Use of `$N' with a `&nosub` field. Closes #2131.
2de6e90 to
c6917d9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So far we would catch pattern errors only at runtime. Now we report
the following at compile time if it can be statically determined:
$Nreferring to a capture group that exceeds the number a pattern defines.for parallel matching (in which case group numbers are ill-defined).
$Nwith a&nosubfield.Closes #2131.