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

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

Issue 1522353002: [regexp] break recursion in mutually recursive capture/back references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: new test expectations Created 5 years 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 | « src/ast/ast.h ('k') | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-visitor.h" 9 #include "src/ast/ast-expression-visitor.h"
10 #include "src/ast/ast-literal-reindexer.h" 10 #include "src/ast/ast-literal-reindexer.h"
(...skipping 5547 matching lines...) Expand 10 before | Expand all | Expand 10 after
5558 CharacterRange::AddClassEscape(c, ranges, zone()); 5558 CharacterRange::AddClassEscape(c, ranges, zone());
5559 RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false); 5559 RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false);
5560 builder->AddAtom(atom); 5560 builder->AddAtom(atom);
5561 break; 5561 break;
5562 } 5562 }
5563 case '1': case '2': case '3': case '4': case '5': case '6': 5563 case '1': case '2': case '3': case '4': case '5': case '6':
5564 case '7': case '8': case '9': { 5564 case '7': case '8': case '9': {
5565 int index = 0; 5565 int index = 0;
5566 if (ParseBackReferenceIndex(&index)) { 5566 if (ParseBackReferenceIndex(&index)) {
5567 if (state->IsInsideCaptureGroup(index)) { 5567 if (state->IsInsideCaptureGroup(index)) {
5568 // The backreference is inside the capture group it refers to. 5568 // The back reference is inside the capture group it refers to.
5569 // Nothing can possibly have been captured yet. 5569 // Nothing can possibly have been captured yet, so we use empty
5570 // instead. This ensures that, when checking a back reference,
5571 // the capture registers of the referenced capture are either
5572 // both set or both cleared.
5570 builder->AddEmpty(); 5573 builder->AddEmpty();
5571 } else { 5574 } else {
5572 RegExpCapture* capture = GetCapture(index); 5575 RegExpCapture* capture = GetCapture(index);
5573 RegExpTree* atom = new (zone()) RegExpBackReference(capture); 5576 RegExpTree* atom = new (zone()) RegExpBackReference(capture);
5574 builder->AddAtom(atom); 5577 builder->AddAtom(atom);
5575 } 5578 }
5576 break; 5579 break;
5577 } 5580 }
5578 uc32 first_digit = Next(); 5581 uc32 first_digit = Next();
5579 if (first_digit == '8' || first_digit == '9') { 5582 if (first_digit == '8' || first_digit == '9') {
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
6588 6591
6589 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) { 6592 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) {
6590 DCHECK(expr->IsRewritableAssignmentExpression()); 6593 DCHECK(expr->IsRewritableAssignmentExpression());
6591 parser_->function_state_->AddDestructuringAssignment( 6594 parser_->function_state_->AddDestructuringAssignment(
6592 Parser::DestructuringAssignment(expr, parser_->scope_)); 6595 Parser::DestructuringAssignment(expr, parser_->scope_));
6593 } 6596 }
6594 6597
6595 6598
6596 } // namespace internal 6599 } // namespace internal
6597 } // namespace v8 6600 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast.h ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698