RegexDefs.h 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2020, Emanuel Sprung <emanuel.sprung@gmail.com>
  3. * Copyright (c) 2020-2022, Ali Mohammad Pur <mpfard@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. enum __Regex_Error {
  9. __Regex_NoError,
  10. __Regex_InvalidPattern, // Invalid regular expression.
  11. __Regex_InvalidCollationElement, // Invalid collating element referenced.
  12. __Regex_InvalidCharacterClass, // Invalid character class type referenced.
  13. __Regex_InvalidTrailingEscape, // Trailing \ in pattern.
  14. __Regex_InvalidNumber, // Number in \digit invalid or in error.
  15. __Regex_MismatchingBracket, // [ ] imbalance.
  16. __Regex_MismatchingParen, // ( ) imbalance.
  17. __Regex_MismatchingBrace, // { } imbalance.
  18. __Regex_InvalidBraceContent, // Content of {} invalid: not a number, number too large, more than two numbers, first larger than second.
  19. __Regex_InvalidBracketContent, // Content of [] invalid.
  20. __Regex_InvalidRange, // Invalid endpoint in range expression.
  21. __Regex_InvalidRepetitionMarker, // ?, * or + not preceded by valid regular expression.
  22. __Regex_ReachedMaxRecursion, // MaximumRecursion has been reached.
  23. __Regex_EmptySubExpression, // Sub expression has empty content.
  24. __Regex_InvalidCaptureGroup, // Content of capture group is invalid.
  25. __Regex_InvalidNameForCaptureGroup, // Name of capture group is invalid.
  26. __Regex_InvalidNameForProperty, // Name of property is invalid.
  27. __Regex_DuplicateNamedCapture, // Duplicate named capture group
  28. __Regex_InvalidCharacterClassEscape, // Invalid escaped entity in character class.
  29. };
  30. enum __RegexAllFlags {
  31. __Regex_Global = 1, // All matches (don't return after first match)
  32. __Regex_Insensitive = __Regex_Global << 1, // Case insensitive match (ignores case of [a-zA-Z])
  33. __Regex_Ungreedy = __Regex_Global << 2, // The match becomes lazy by default. Now a ? following a quantifier makes it greedy
  34. __Regex_Unicode = __Regex_Global << 3, // Enable all unicode features and interpret all unicode escape sequences as such
  35. __Regex_Extended = __Regex_Global << 4, // Ignore whitespaces. Spaces and text after a # in the pattern are ignored
  36. __Regex_Extra = __Regex_Global << 5, // Disallow meaningless escapes. A \ followed by a letter with no special meaning is faulted
  37. __Regex_MatchNotBeginOfLine = __Regex_Global << 6, // Pattern is not forced to ^ -> search in whole string!
  38. __Regex_MatchNotEndOfLine = __Regex_Global << 7, // 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
  39. __Regex_SkipSubExprResults = __Regex_Global << 8, // Do not return sub expressions in the result
  40. __Regex_StringCopyMatches = __Regex_Global << 9, // Do explicitly copy results into new allocated string instead of StringView to original string.
  41. __Regex_SingleLine = __Regex_Global << 10, // Dot matches newline characters
  42. __Regex_Sticky = __Regex_Global << 11, // Force the pattern to only match consecutive matches from where the previous match ended.
  43. __Regex_Multiline = __Regex_Global << 12, // Handle newline characters. Match each line, one by one.
  44. __Regex_SkipTrimEmptyMatches = __Regex_Global << 13, // Do not remove empty capture group results.
  45. __Regex_SingleMatch = __Regex_Global << 14, // Stop after acquiring a single match.
  46. __Regex_UnicodeSets = __Regex_Global << 15, // ECMA262 Parser specific: Allow set operations in char classes.
  47. __Regex_Internal_Stateful = __Regex_Global << 16, // Internal flag; enables stateful matches.
  48. __Regex_Internal_BrowserExtended = __Regex_Global << 17, // Internal flag; enable browser-specific ECMA262 extensions.
  49. __Regex_Internal_ConsiderNewline = __Regex_Global << 18, // Internal flag; allow matchers to consider newlines as line separators.
  50. __Regex_Internal_ECMA262DotSemantics = __Regex_Global << 19, // Internal flag; use ECMA262 semantics for dot ('.') - disallow CR/LF/LS/PS instead of just CR.
  51. __Regex_Last = __Regex_Internal_ECMA262DotSemantics,
  52. };