| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |