diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2021-02-26 22:49:34 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-27 07:31:01 +0100 |
commit | f05e518cbc4e1f7122d10a1408c3f76ad098802b (patch) | |
tree | 93865d77e4c38bb5a483d11e3305084e9b9cd8d4 /Userland/Libraries/LibRegex/RegexOptions.h | |
parent | ce5fe2a6e807b819866b4f429ca6f7a2d74445b7 (diff) | |
download | serenity-f05e518cbc4e1f7122d10a1408c3f76ad098802b.zip |
LibRegex: Implement section B.1.4. of the ECMA262 spec
This allows the parser to deal with crazy patterns like the one
in #5517.
Diffstat (limited to 'Userland/Libraries/LibRegex/RegexOptions.h')
-rw-r--r-- | Userland/Libraries/LibRegex/RegexOptions.h | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/Userland/Libraries/LibRegex/RegexOptions.h b/Userland/Libraries/LibRegex/RegexOptions.h index 5e860215fd..0279b7c803 100644 --- a/Userland/Libraries/LibRegex/RegexOptions.h +++ b/Userland/Libraries/LibRegex/RegexOptions.h @@ -39,22 +39,23 @@ namespace regex { using FlagsUnderlyingType = u16; enum class AllFlags { - Global = __Regex_Global, // All matches (don't return after first match) - Insensitive = __Regex_Insensitive, // Case insensitive match (ignores case of [a-zA-Z]) - Ungreedy = __Regex_Ungreedy, // The match becomes lazy by default. Now a ? following a quantifier makes it greedy - Unicode = __Regex_Unicode, // Enable all unicode features and interpret all unicode escape sequences as such - Extended = __Regex_Extended, // Ignore whitespaces. Spaces and text after a # in the pattern are ignored - Extra = __Regex_Extra, // Disallow meaningless escapes. A \ followed by a letter with no special meaning is faulted - MatchNotBeginOfLine = __Regex_MatchNotBeginOfLine, // Pattern is not forced to ^ -> search in whole string! - MatchNotEndOfLine = __Regex_MatchNotEndOfLine, // Don't Force the dollar sign, $, to always match end of the string, instead of end of the line. This option is ignored if the Multiline-flag is set - SkipSubExprResults = __Regex_SkipSubExprResults, // Do not return sub expressions in the result - StringCopyMatches = __Regex_StringCopyMatches, // Do explicitly copy results into new allocated string instead of StringView to original string. - SingleLine = __Regex_SingleLine, // Dot matches newline characters - Sticky = __Regex_Sticky, // Force the pattern to only match consecutive matches from where the previous match ended. - Multiline = __Regex_Multiline, // Handle newline characters. Match each line, one by one. - SkipTrimEmptyMatches = __Regex_SkipTrimEmptyMatches, // Do not remove empty capture group results. - Internal_Stateful = __Regex_Internal_Stateful, // Make global matches match one result at a time, and further match() calls on the same instance continue where the previous one left off. - Last = Internal_Stateful, + Global = __Regex_Global, // All matches (don't return after first match) + Insensitive = __Regex_Insensitive, // Case insensitive match (ignores case of [a-zA-Z]) + Ungreedy = __Regex_Ungreedy, // The match becomes lazy by default. Now a ? following a quantifier makes it greedy + Unicode = __Regex_Unicode, // Enable all unicode features and interpret all unicode escape sequences as such + Extended = __Regex_Extended, // Ignore whitespaces. Spaces and text after a # in the pattern are ignored + Extra = __Regex_Extra, // Disallow meaningless escapes. A \ followed by a letter with no special meaning is faulted + MatchNotBeginOfLine = __Regex_MatchNotBeginOfLine, // Pattern is not forced to ^ -> search in whole string! + MatchNotEndOfLine = __Regex_MatchNotEndOfLine, // Don't Force the dollar sign, $, to always match end of the string, instead of end of the line. This option is ignored if the Multiline-flag is set + SkipSubExprResults = __Regex_SkipSubExprResults, // Do not return sub expressions in the result + StringCopyMatches = __Regex_StringCopyMatches, // Do explicitly copy results into new allocated string instead of StringView to original string. + SingleLine = __Regex_SingleLine, // Dot matches newline characters + Sticky = __Regex_Sticky, // Force the pattern to only match consecutive matches from where the previous match ended. + Multiline = __Regex_Multiline, // Handle newline characters. Match each line, one by one. + SkipTrimEmptyMatches = __Regex_SkipTrimEmptyMatches, // Do not remove empty capture group results. + Internal_Stateful = __Regex_Internal_Stateful, // Make global matches match one result at a time, and further match() calls on the same instance continue where the previous one left off. + Internal_BrowserExtended = __Regex_Internal_BrowserExtended, // Only for ECMA262, Enable the behaviours defined in section B.1.4. of the ECMA262 spec. + Last = Internal_BrowserExtended, }; enum class PosixFlags : FlagsUnderlyingType { @@ -83,6 +84,7 @@ enum class ECMAScriptFlags : FlagsUnderlyingType { Sticky = (FlagsUnderlyingType)AllFlags::Sticky, Multiline = (FlagsUnderlyingType)AllFlags::Multiline, StringCopyMatches = (FlagsUnderlyingType)AllFlags::StringCopyMatches, + BrowserExtended = (FlagsUnderlyingType)AllFlags::Internal_BrowserExtended, }; template<class T> |