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 "src/base/logging.h" 9 #include "src/base/macros.h" 10 11 namespace v8 { 12 namespace internal { 13 14 #define REGEXP_ERROR_MESSAGES(T) \ 15 T(None, "") \ 16 T(StackOverflow, "Maximum call stack size exceeded") \ 17 T(AnalysisStackOverflow, "Stack overflow") \ 18 T(TooLarge, "Regular expression too large") \ 19 T(UnterminatedGroup, "Unterminated group") \ 20 T(UnmatchedParen, "Unmatched ')'") \ 21 T(EscapeAtEndOfPattern, "\\ at end of pattern") \ 22 T(InvalidPropertyName, "Invalid property name") \ 23 T(InvalidEscape, "Invalid escape") \ 24 T(InvalidDecimalEscape, "Invalid decimal escape") \ 25 T(InvalidUnicodeEscape, "Invalid Unicode escape") \ 26 T(NothingToRepeat, "Nothing to repeat") \ 27 T(LoneQuantifierBrackets, "Lone quantifier brackets") \ 28 T(RangeOutOfOrder, "numbers out of order in {} quantifier") \ 29 T(IncompleteQuantifier, "Incomplete quantifier") \ 30 T(InvalidQuantifier, "Invalid quantifier") \ 31 T(InvalidGroup, "Invalid group") \ 32 T(MultipleFlagDashes, "Multiple dashes in flag group") \ 33 T(NotLinear, "Cannot be executed in linear time") \ 34 T(RepeatedFlag, "Repeated flag in flag group") \ 35 T(InvalidFlagGroup, "Invalid flag group") \ 36 T(TooManyCaptures, "Too many captures") \ 37 T(InvalidCaptureGroupName, "Invalid capture group name") \ 38 T(DuplicateCaptureGroupName, "Duplicate capture group name") \ 39 T(InvalidNamedReference, "Invalid named reference") \ 40 T(InvalidNamedCaptureReference, "Invalid named capture referenced") \ 41 T(InvalidClassEscape, "Invalid class escape") \ 42 T(InvalidClassPropertyName, "Invalid property name in character class") \ 43 T(InvalidCharacterClass, "Invalid character class") \ 44 T(UnterminatedCharacterClass, "Unterminated character class") \ 45 T(OutOfOrderCharacterClass, "Range out of order in character class") 46 47 enum class RegExpError : uint32_t { 48 #define TEMPLATE(NAME, STRING) k##NAME, 49 REGEXP_ERROR_MESSAGES(TEMPLATE) 50 #undef TEMPLATE 51 NumErrors 52 }; 53 54 V8_EXPORT_PRIVATE const char* RegExpErrorString(RegExpError error); 55 56 } // namespace internal 57 } // namespace v8 58 59 #endif // V8_REGEXP_REGEXP_ERROR_H_ 60