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 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 } | 905 } |
906 DCHECK_EQ(U_ZERO_ERROR, ec); | 906 DCHECK_EQ(U_ZERO_ERROR, ec); |
907 DCHECK_EQ(0, item_result); | 907 DCHECK_EQ(0, item_result); |
908 } | 908 } |
909 uset_close(set); | 909 uset_close(set); |
910 return success; | 910 return success; |
911 } | 911 } |
912 | 912 |
913 bool RegExpParser::ParsePropertyClass(ZoneList<CharacterRange>* result) { | 913 bool RegExpParser::ParsePropertyClass(ZoneList<CharacterRange>* result) { |
914 // Parse the property class as follows: | 914 // Parse the property class as follows: |
915 // - \pN with a single-character N is equivalent to \p{N} | |
916 // - In \p{name}, 'name' is interpreted | 915 // - In \p{name}, 'name' is interpreted |
917 // - either as a general category property value name. | 916 // - either as a general category property value name. |
918 // - or as a binary property name. | 917 // - or as a binary property name. |
919 // - In \p{name=value}, 'name' is interpreted as an enumerated property name, | 918 // - In \p{name=value}, 'name' is interpreted as an enumerated property name, |
920 // and 'value' is interpreted as one of the available property value names. | 919 // and 'value' is interpreted as one of the available property value names. |
921 // - Aliases in PropertyAlias.txt and PropertyValueAlias.txt can be used. | 920 // - Aliases in PropertyAlias.txt and PropertyValueAlias.txt can be used. |
922 // - Loose matching is not applied. | 921 // - Loose matching is not applied. |
923 List<char> first_part; | 922 List<char> first_part; |
924 List<char> second_part; | 923 List<char> second_part; |
925 if (current() == '{') { | 924 if (current() == '{') { |
926 // Parse \p{[PropertyName=]PropertyNameValue} | 925 // Parse \p{[PropertyName=]PropertyNameValue} |
927 for (Advance(); current() != '}' && current() != '='; Advance()) { | 926 for (Advance(); current() != '}' && current() != '='; Advance()) { |
928 if (!has_next()) return false; | 927 if (!has_next()) return false; |
929 first_part.Add(static_cast<char>(current())); | 928 first_part.Add(static_cast<char>(current())); |
930 } | 929 } |
931 if (current() == '=') { | 930 if (current() == '=') { |
932 for (Advance(); current() != '}'; Advance()) { | 931 for (Advance(); current() != '}'; Advance()) { |
933 if (!has_next()) return false; | 932 if (!has_next()) return false; |
934 second_part.Add(static_cast<char>(current())); | 933 second_part.Add(static_cast<char>(current())); |
935 } | 934 } |
936 second_part.Add(0); // null-terminate string. | 935 second_part.Add(0); // null-terminate string. |
937 } | 936 } |
938 } else if (current() != kEndMarker) { | |
939 // Parse \pN, where N is a single-character property name value. | |
940 first_part.Add(static_cast<char>(current())); | |
941 } else { | 937 } else { |
942 return false; | 938 return false; |
943 } | 939 } |
944 Advance(); | 940 Advance(); |
945 first_part.Add(0); // null-terminate string. | 941 first_part.Add(0); // null-terminate string. |
946 | 942 |
947 if (second_part.is_empty()) { | 943 if (second_part.is_empty()) { |
948 // First attempt to interpret as general category property value name. | 944 // First attempt to interpret as general category property value name. |
949 const char* name = first_part.ToConstVector().start(); | 945 const char* name = first_part.ToConstVector().start(); |
950 if (LookupPropertyValueName(UCHAR_GENERAL_CATEGORY_MASK, name, result, | 946 if (LookupPropertyValueName(UCHAR_GENERAL_CATEGORY_MASK, name, result, |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1561 return false; | 1557 return false; |
1562 } | 1558 } |
1563 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1559 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
1564 zone()); | 1560 zone()); |
1565 LAST(ADD_TERM); | 1561 LAST(ADD_TERM); |
1566 return true; | 1562 return true; |
1567 } | 1563 } |
1568 | 1564 |
1569 } // namespace internal | 1565 } // namespace internal |
1570 } // namespace v8 | 1566 } // namespace v8 |
OLD | NEW |