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

Side by Side Diff: src/parser.cc

Issue 6499016: Fix bug 1137. No longer allow the RegExp /(*)/. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build-ia32
Patch Set: Created 9 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regexp.js » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 4255 matching lines...) Expand 10 before | Expand all | Expand 10 after
4266 body = capture; 4266 body = capture;
4267 } else if (type != GROUPING) { 4267 } else if (type != GROUPING) {
4268 ASSERT(type == POSITIVE_LOOKAHEAD || type == NEGATIVE_LOOKAHEAD); 4268 ASSERT(type == POSITIVE_LOOKAHEAD || type == NEGATIVE_LOOKAHEAD);
4269 bool is_positive = (type == POSITIVE_LOOKAHEAD); 4269 bool is_positive = (type == POSITIVE_LOOKAHEAD);
4270 body = new RegExpLookahead(body, 4270 body = new RegExpLookahead(body,
4271 is_positive, 4271 is_positive,
4272 end_capture_index - capture_index, 4272 end_capture_index - capture_index,
4273 capture_index); 4273 capture_index);
4274 } 4274 }
4275 builder->AddAtom(body); 4275 builder->AddAtom(body);
4276 // For compatability with JSC and ES3, we allow quantifiers after
4277 // lookaheads, and break in all cases.
4276 break; 4278 break;
4277 } 4279 }
4278 case '|': { 4280 case '|': {
4279 Advance(); 4281 Advance();
4280 builder->NewAlternative(); 4282 builder->NewAlternative();
4281 continue; 4283 continue;
4282 } 4284 }
4283 case '*': 4285 case '*':
4284 case '+': 4286 case '+':
4285 case '?': 4287 case '?':
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4339 if (captures_started() >= kMaxCaptures) { 4341 if (captures_started() >= kMaxCaptures) {
4340 ReportError(CStrVector("Too many captures") CHECK_FAILED); 4342 ReportError(CStrVector("Too many captures") CHECK_FAILED);
4341 } 4343 }
4342 captures_->Add(NULL); 4344 captures_->Add(NULL);
4343 } 4345 }
4344 // Store current state and begin new disjunction parsing. 4346 // Store current state and begin new disjunction parsing.
4345 stored_state = new RegExpParserState(stored_state, 4347 stored_state = new RegExpParserState(stored_state,
4346 type, 4348 type,
4347 captures_started()); 4349 captures_started());
4348 builder = stored_state->builder(); 4350 builder = stored_state->builder();
4349 break; 4351 continue;
4350 } 4352 }
4351 case '[': { 4353 case '[': {
4352 RegExpTree* atom = ParseCharacterClass(CHECK_FAILED); 4354 RegExpTree* atom = ParseCharacterClass(CHECK_FAILED);
4353 builder->AddAtom(atom); 4355 builder->AddAtom(atom);
4354 break; 4356 break;
4355 } 4357 }
4356 // Atom :: 4358 // Atom ::
4357 // \ AtomEscape 4359 // \ AtomEscape
4358 case '\\': 4360 case '\\':
4359 switch (Next()) { 4361 switch (Next()) {
4360 case kEndMarker: 4362 case kEndMarker:
4361 return ReportError(CStrVector("\\ at end of pattern")); 4363 return ReportError(CStrVector("\\ at end of pattern"));
4362 case 'b': 4364 case 'b':
4363 Advance(2); 4365 Advance(2);
4364 builder->AddAssertion( 4366 builder->AddAssertion(
4365 new RegExpAssertion(RegExpAssertion::BOUNDARY)); 4367 new RegExpAssertion(RegExpAssertion::BOUNDARY));
4366 continue; 4368 continue;
4367 case 'B': 4369 case 'B':
4368 Advance(2); 4370 Advance(2);
4369 builder->AddAssertion( 4371 builder->AddAssertion(
4370 new RegExpAssertion(RegExpAssertion::NON_BOUNDARY)); 4372 new RegExpAssertion(RegExpAssertion::NON_BOUNDARY));
4371 continue; 4373 continue;
4372 // AtomEscape :: 4374 // AtomEscape ::
4373 // CharacterClassEscape 4375 // CharacterClassEscape
4374 // 4376 //
4375 // CharacterClassEscape :: one of 4377 // CharacterClassEscape :: one of
4376 // d D s S w W 4378 // d D s S w W
4377 case 'd': case 'D': case 's': case 'S': case 'w': case 'W': { 4379 case 'd': case 'D': case 's': case 'S': case 'w': case 'W': {
4378 uc32 c = Next(); 4380 uc32 c = Next();
4379 Advance(2); 4381 Advance(2);
4380 ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2); 4382 ZoneList<CharacterRange>* ranges = new ZoneList<CharacterRange>(2);
4381 CharacterRange::AddClassEscape(c, ranges); 4383 CharacterRange::AddClassEscape(c, ranges);
4382 RegExpTree* atom = new RegExpCharacterClass(ranges, false); 4384 RegExpTree* atom = new RegExpCharacterClass(ranges, false);
4383 builder->AddAtom(atom); 4385 builder->AddAtom(atom);
4384 break; 4386 break;
4385 } 4387 }
4386 case '1': case '2': case '3': case '4': case '5': case '6': 4388 case '1': case '2': case '3': case '4': case '5': case '6':
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
5112 info->is_global(), 5114 info->is_global(),
5113 info->StrictMode()); 5115 info->StrictMode());
5114 } 5116 }
5115 } 5117 }
5116 5118
5117 info->SetFunction(result); 5119 info->SetFunction(result);
5118 return (result != NULL); 5120 return (result != NULL);
5119 } 5121 }
5120 5122
5121 } } // namespace v8::internal 5123 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698