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

Side by Side Diff: src/regexp/regexp-parser.cc

Issue 2792523002: [regexp] Fix numbered reference before named capture (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | test/mjsunit/harmony/regexp-named-captures.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/regexp/regexp-parser.h" 5 #include "src/regexp/regexp-parser.h"
6 6
7 #include "src/char-predicates-inl.h" 7 #include "src/char-predicates-inl.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 Advance(); 663 Advance();
664 if (c == '\\') { 664 if (c == '\\') {
665 Advance(); 665 Advance();
666 } else { 666 } else {
667 if (c == ']') break; 667 if (c == ']') break;
668 } 668 }
669 } 669 }
670 break; 670 break;
671 } 671 }
672 case '(': 672 case '(':
673 if (current() != '?') capture_count++; 673 if (current() == '?') {
674 // At this point we could be in
675 // * a non-capturing group '(:',
676 // * a lookbehind assertion '(?<=' '(?<!'
677 // * or a named capture '(?<'.
678 //
679 // Of these, only named captures are capturing groups.
680 if (!FLAG_harmony_regexp_named_captures) break;
681
682 Advance();
683 if (current() != '<') break;
684
685 // TODO(jgruber): To be more future-proof we could test for
686 // IdentifierStart here once it becomes clear whether group names
687 // allow unicode escapes.
688 Advance();
689 if (current() == '=' || current() == '!') break;
690 }
691 capture_count++;
674 break; 692 break;
675 } 693 }
676 } 694 }
677 capture_count_ = capture_count; 695 capture_count_ = capture_count;
678 is_scanned_for_captures_ = true; 696 is_scanned_for_captures_ = true;
679 } 697 }
680 698
681 699
682 bool RegExpParser::ParseBackReferenceIndex(int* index_out) { 700 bool RegExpParser::ParseBackReferenceIndex(int* index_out) {
683 DCHECK_EQ('\\', current()); 701 DCHECK_EQ('\\', current());
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 return false; 1828 return false;
1811 } 1829 }
1812 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), 1830 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom),
1813 zone()); 1831 zone());
1814 LAST(ADD_TERM); 1832 LAST(ADD_TERM);
1815 return true; 1833 return true;
1816 } 1834 }
1817 1835
1818 } // namespace internal 1836 } // namespace internal
1819 } // namespace v8 1837 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/regexp-named-captures.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698