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.
Fixes #2837; see that issue for further discussion.
The regex-syntax crate natively supports
\!
,\'
,\"
, and\/
identity escapes now, so we don't need to preprocess the regex in order to support those.Unescaped
{}
are only permitted in Unicode-unaware JS regexp, and that syntax is deprecated, only kept for web compatibility, and should not be relied upon. In Unicode-aware JS regexp (via theu
orv
flag), unescaped{}
are syntax errors. Unicode-aware mode is required for support for\u{hhhh}
or\p{UnicodeProperty}
syntaxes, which Tree-sitter always supports.The current behavior is sort of a "worst of both worlds" where Tree-sitter's regex flavor is neither Rust nor ECMAScript compatible. Removing the special curly brace preprocessing means Tree-sitter's regex now matches Rust flavor again and moves it closer to that of ECMAScript in
u
orv
mode. (And the divergences, unlike unescaped{}
, are much less likely to be hit unintentionally.) And even though this means any previously-preprocessed regex will change meaning, it will always1 be changed to emit a clear error pointing out the{
which now needs to be manually escaped.Changelog
{
now need to be escaped outside of[]
. If this occurs in your grammar, Tree-sitter will error, indicating the regex which needs to be edited.Footnotes
Well, almost always. In the specific case of
\b{start}
,\b{end}
,\b{start-half}
, or\b{end-half}
, the pre-preprocessing version is valid with a different meaning. ↩