Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 160f0f784489a409ab49d44b18edfc16dacdcc3b..fd93aae4241d7494dc26522ca4904081e746c4eb 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -4452,7 +4452,6 @@ CharacterRange RegExpParser::ParseClassAtom(uc16* char_class) { |
RegExpTree* RegExpParser::ParseCharacterClass() { |
static const char* kUnterminated = "Unterminated character class"; |
static const char* kRangeOutOfOrder = "Range out of order in character class"; |
- static const char* kInvalidRange = "Invalid character range"; |
ASSERT_EQ(current(), '['); |
Advance(); |
@@ -4461,28 +4460,12 @@ RegExpTree* RegExpParser::ParseCharacterClass() { |
is_negated = true; |
Advance(); |
} |
- // A CharacterClass is a sequence of single characters, character class |
- // escapes or ranges. Ranges are on the form "x-y" where x and y are |
- // single characters (and not character class escapes like \s). |
- // A "-" may occur at the start or end of the character class (just after |
- // "[" or "[^", or just before "]") without being considered part of a |
- // range. A "-" may also appear as the beginning or end of a range. |
- // I.e., [--+] is valid, so is [!--]. |
- |
ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2); |
while (has_more() && current() != ']') { |
uc16 char_class = 0; |
CharacterRange first = ParseClassAtom(&char_class CHECK_FAILED); |
if (char_class) { |
CharacterRange::AddClassEscape(char_class, ranges); |
- if (current() == '-') { |
- Advance(); |
- ranges->Add(CharacterRange::Singleton('-')); |
- if (current() != ']') { |
- ReportError(CStrVector(kInvalidRange) CHECK_FAILED); |
- } |
- break; |
- } |
continue; |
} |
if (current() == '-') { |
@@ -4498,7 +4481,10 @@ RegExpTree* RegExpParser::ParseCharacterClass() { |
} |
CharacterRange next = ParseClassAtom(&char_class CHECK_FAILED); |
if (char_class) { |
- ReportError(CStrVector(kInvalidRange) CHECK_FAILED); |
+ ranges->Add(first); |
+ ranges->Add(CharacterRange::Singleton('-')); |
+ CharacterRange::AddClassEscape(char_class, ranges); |
+ continue; |
} |
if (first.from() > next.to()) { |
return ReportError(CStrVector(kRangeOutOfOrder) CHECK_FAILED); |