Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: regexp2000/src/parser.cc

Issue 9692: * Fix bug in regexp parser. (Closed)
Patch Set: Addressed review comments Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « regexp2000/src/jsregexp.cc ('k') | regexp2000/test/cctest/test-regexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4046 matching lines...) Expand 10 before | Expand all | Expand 10 after
4057 4057
4058 ASSERT_EQ(current(), '['); 4058 ASSERT_EQ(current(), '[');
4059 Advance(); 4059 Advance();
4060 bool is_negated = false; 4060 bool is_negated = false;
4061 if (current() == '^') { 4061 if (current() == '^') {
4062 is_negated = true; 4062 is_negated = true;
4063 Advance(); 4063 Advance();
4064 } 4064 }
4065 ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2); 4065 ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
4066 while (has_more() && current() != ']') { 4066 while (has_more() && current() != ']') {
4067 if (current() == '-') { 4067 bool is_char_class = false;
4068 Advance(); 4068 CharacterRange first = ParseClassAtom(&is_char_class, ranges, CHECK_OK);
4069 ranges->Add(CharacterRange::Singleton('-')); 4069 if (!is_char_class) {
4070 } else { 4070 if (current() == '-') {
4071 bool is_char_class = false; 4071 Advance();
4072 CharacterRange first = ParseClassAtom(&is_char_class, ranges, CHECK_OK); 4072 if (current() == ']') {
4073 if (!is_char_class) {
4074 if (current() == '-') {
4075 Advance();
4076 CharacterRange next =
4077 ParseClassAtom(&is_char_class, ranges, CHECK_OK);
4078 if (is_char_class) {
4079 return ReportError(CStrVector(kIllegal), CHECK_OK);
4080 }
4081 if (first.from() > next.to()) {
4082 return ReportError(CStrVector(kRangeOutOfOrder), CHECK_OK);
4083 }
4084 ranges->Add(CharacterRange::Range(first.from(), next.to()));
4085 } else {
4086 ranges->Add(first); 4073 ranges->Add(first);
4074 ranges->Add(CharacterRange::Singleton('-'));
4075 break;
4087 } 4076 }
4077 CharacterRange next =
4078 ParseClassAtom(&is_char_class, ranges, CHECK_OK);
4079 if (is_char_class) {
4080 return ReportError(CStrVector(kIllegal), CHECK_OK);
4081 }
4082 if (first.from() > next.to()) {
4083 return ReportError(CStrVector(kRangeOutOfOrder), CHECK_OK);
4084 }
4085 ranges->Add(CharacterRange::Range(first.from(), next.to()));
4086 } else {
4087 ranges->Add(first);
4088 } 4088 }
4089 } 4089 }
4090 } 4090 }
4091 if (!has_more()) { 4091 if (!has_more()) {
4092 return ReportError(CStrVector(kUnterminated), CHECK_OK); 4092 return ReportError(CStrVector(kUnterminated), CHECK_OK);
4093 } 4093 }
4094 Advance(); 4094 Advance();
4095 if (ranges->length() == 0) { 4095 if (ranges->length() == 0) {
4096 return RegExpEmpty::GetInstance(); 4096 return RegExpEmpty::GetInstance();
4097 } else { 4097 } else {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4214 start_position, 4214 start_position,
4215 is_expression); 4215 is_expression);
4216 return result; 4216 return result;
4217 } 4217 }
4218 4218
4219 4219
4220 #undef NEW 4220 #undef NEW
4221 4221
4222 4222
4223 } } // namespace v8::internal 4223 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « regexp2000/src/jsregexp.cc ('k') | regexp2000/test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698