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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 if (c == '\\' && current() == 'u') { | 782 if (c == '\\' && current() == 'u') { |
783 // TODO(jgruber): Reconsider this once the spec has settled. | 783 // TODO(jgruber): Reconsider this once the spec has settled. |
784 // https://github.com/tc39/proposal-regexp-named-groups/issues/23 | 784 // https://github.com/tc39/proposal-regexp-named-groups/issues/23 |
785 Advance(); | 785 Advance(); |
786 if (!ParseUnicodeEscape(&c)) { | 786 if (!ParseUnicodeEscape(&c)) { |
787 ReportError(CStrVector("Invalid Unicode escape sequence")); | 787 ReportError(CStrVector("Invalid Unicode escape sequence")); |
788 return nullptr; | 788 return nullptr; |
789 } | 789 } |
790 } | 790 } |
791 | 791 |
| 792 // The backslash char is misclassified as both ID_Start and ID_Continue. |
| 793 if (c == '\\') { |
| 794 ReportError(CStrVector("Invalid capture group name")); |
| 795 return nullptr; |
| 796 } |
| 797 |
792 if (at_start) { | 798 if (at_start) { |
793 if (!IdentifierStart::Is(c)) { | 799 if (!IdentifierStart::Is(c)) { |
794 ReportError(CStrVector("Invalid capture group name")); | 800 ReportError(CStrVector("Invalid capture group name")); |
795 return nullptr; | 801 return nullptr; |
796 } | 802 } |
797 push_code_unit(name, c); | 803 push_code_unit(name, c); |
798 at_start = false; | 804 at_start = false; |
799 } else { | 805 } else { |
800 if (c == '>') { | 806 if (c == '>') { |
801 break; | 807 break; |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 return false; | 1870 return false; |
1865 } | 1871 } |
1866 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1872 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
1867 zone()); | 1873 zone()); |
1868 LAST(ADD_TERM); | 1874 LAST(ADD_TERM); |
1869 return true; | 1875 return true; |
1870 } | 1876 } |
1871 | 1877 |
1872 } // namespace internal | 1878 } // namespace internal |
1873 } // namespace v8 | 1879 } // namespace v8 |
OLD | NEW |