regexp-error.h (3418B)
1 // Copyright 2020 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_REGEXP_REGEXP_ERROR_H_ 6 #define V8_REGEXP_REGEXP_ERROR_H_ 7 8 #include "irregexp/RegExpShim.h" 9 10 namespace v8 { 11 namespace internal { 12 13 #define REGEXP_ERROR_MESSAGES(T) \ 14 T(None, "") \ 15 T(StackOverflow, "Maximum call stack size exceeded") \ 16 T(AnalysisStackOverflow, "Stack overflow") \ 17 T(TooLarge, "Regular expression too large") \ 18 T(UnterminatedGroup, "Unterminated group") \ 19 T(UnmatchedParen, "Unmatched ')'") \ 20 T(EscapeAtEndOfPattern, "\\ at end of pattern") \ 21 T(InvalidPropertyName, "Invalid property name") \ 22 T(InvalidEscape, "Invalid escape") \ 23 T(InvalidDecimalEscape, "Invalid decimal escape") \ 24 T(InvalidUnicodeEscape, "Invalid Unicode escape") \ 25 T(NothingToRepeat, "Nothing to repeat") \ 26 T(LoneQuantifierBrackets, "Lone quantifier brackets") \ 27 T(RangeOutOfOrder, "numbers out of order in {} quantifier") \ 28 T(IncompleteQuantifier, "Incomplete quantifier") \ 29 T(InvalidQuantifier, "Invalid quantifier") \ 30 T(InvalidGroup, "Invalid group") \ 31 T(MultipleFlagDashes, "Multiple dashes in flag group") \ 32 T(NotLinear, "Cannot be executed in linear time") \ 33 T(RepeatedFlag, "Repeated flag in flag group") \ 34 T(InvalidFlagGroup, "Invalid flag group") \ 35 T(TooManyCaptures, "Too many captures") \ 36 T(InvalidCaptureGroupName, "Invalid capture group name") \ 37 T(DuplicateCaptureGroupName, "Duplicate capture group name") \ 38 T(InvalidNamedReference, "Invalid named reference") \ 39 T(InvalidNamedCaptureReference, "Invalid named capture referenced") \ 40 T(InvalidClassPropertyName, "Invalid property name in character class") \ 41 T(InvalidCharacterClass, "Invalid character class") \ 42 T(UnterminatedCharacterClass, "Unterminated character class") \ 43 T(OutOfOrderCharacterClass, "Range out of order in character class") \ 44 T(InvalidClassSetOperation, "Invalid set operation in character class") \ 45 T(InvalidCharacterInClass, "Invalid character in character class") \ 46 T(NegatedCharacterClassWithStrings, \ 47 "Negated character class may contain strings") 48 49 enum class RegExpError : uint32_t { 50 #define TEMPLATE(NAME, STRING) k##NAME, 51 REGEXP_ERROR_MESSAGES(TEMPLATE) 52 #undef TEMPLATE 53 NumErrors 54 }; 55 56 V8_EXPORT_PRIVATE const char* RegExpErrorString(RegExpError error); 57 58 inline constexpr bool RegExpErrorIsStackOverflow(RegExpError error) { 59 return error == RegExpError::kStackOverflow || 60 error == RegExpError::kAnalysisStackOverflow; 61 } 62 63 } // namespace internal 64 } // namespace v8 65 66 #endif // V8_REGEXP_REGEXP_ERROR_H_