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

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

Issue 2502933002: [regexp] implement latest spec draft for property class. (Closed)
Patch Set: fix test Created 4 years, 1 month 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
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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 static_cast<UPropertyNameChoice>(U_LONG_PROPERTY_NAME + i)); 1075 static_cast<UPropertyNameChoice>(U_LONG_PROPERTY_NAME + i));
1076 if (long_name == NULL) break; 1076 if (long_name == NULL) break;
1077 if (strcmp(property_value_name, long_name) == 0) return true; 1077 if (strcmp(property_value_name, long_name) == 0) return true;
1078 } 1078 }
1079 return false; 1079 return false;
1080 } 1080 }
1081 1081
1082 bool LookupPropertyValueName(UProperty property, 1082 bool LookupPropertyValueName(UProperty property,
1083 const char* property_value_name, bool negate, 1083 const char* property_value_name, bool negate,
1084 ZoneList<CharacterRange>* result, Zone* zone) { 1084 ZoneList<CharacterRange>* result, Zone* zone) {
1085 UProperty property_for_lookup = property;
1086 if (property_for_lookup == UCHAR_SCRIPT_EXTENSIONS) {
1087 // For the property Script_Extensions, we have to do the property value
1088 // name lookup as if the property is Script.
1089 property_for_lookup = UCHAR_SCRIPT;
1090 }
1085 int32_t property_value = 1091 int32_t property_value =
1086 u_getPropertyValueEnum(property, property_value_name); 1092 u_getPropertyValueEnum(property_for_lookup, property_value_name);
1087 if (property_value == UCHAR_INVALID_CODE) return false; 1093 if (property_value == UCHAR_INVALID_CODE) return false;
1088 1094
1089 // We require the property name to match exactly to one of the property value 1095 // We require the property name to match exactly to one of the property value
1090 // aliases. However, u_getPropertyValueEnum uses loose matching. 1096 // aliases. However, u_getPropertyValueEnum uses loose matching.
1091 if (!IsExactPropertyValueAlias(property_value_name, property, 1097 if (!IsExactPropertyValueAlias(property_value_name, property_for_lookup,
1092 property_value)) { 1098 property_value)) {
1093 return false; 1099 return false;
1094 } 1100 }
1095 1101
1096 USet* set = uset_openEmpty(); 1102 USet* set = uset_openEmpty();
1097 UErrorCode ec = U_ZERO_ERROR; 1103 UErrorCode ec = U_ZERO_ERROR;
1098 uset_applyIntPropertyValue(set, property, property_value, &ec); 1104 uset_applyIntPropertyValue(set, property, property_value, &ec);
1099 bool success = ec == U_ZERO_ERROR && !uset_isEmpty(set); 1105 bool success = ec == U_ZERO_ERROR && !uset_isEmpty(set);
1100 1106
1101 if (success) { 1107 if (success) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 if (property >= UCHAR_BINARY_LIMIT) return false; 1195 if (property >= UCHAR_BINARY_LIMIT) return false;
1190 if (!IsExactPropertyAlias(name, property)) return false; 1196 if (!IsExactPropertyAlias(name, property)) return false;
1191 return LookupPropertyValueName(property, negate ? "N" : "Y", false, result, 1197 return LookupPropertyValueName(property, negate ? "N" : "Y", false, result,
1192 zone()); 1198 zone());
1193 } else { 1199 } else {
1194 // Both property name and value name are specified. Attempt to interpret 1200 // Both property name and value name are specified. Attempt to interpret
1195 // the property name as enumerated property. 1201 // the property name as enumerated property.
1196 const char* property_name = first_part.ToConstVector().start(); 1202 const char* property_name = first_part.ToConstVector().start();
1197 const char* value_name = second_part.ToConstVector().start(); 1203 const char* value_name = second_part.ToConstVector().start();
1198 UProperty property = u_getPropertyEnum(property_name); 1204 UProperty property = u_getPropertyEnum(property_name);
1199 if (property < UCHAR_INT_START) return false; 1205 if (property != UCHAR_SCRIPT && property != UCHAR_SCRIPT_EXTENSIONS) {
1200 if (property >= UCHAR_INT_LIMIT) return false; 1206 return false;
1207 }
Dan Ehrenberg 2016/11/16 17:54:52 You're removing more than support for blocks here.
1201 if (!IsExactPropertyAlias(property_name, property)) return false; 1208 if (!IsExactPropertyAlias(property_name, property)) return false;
1202 return LookupPropertyValueName(property, value_name, negate, result, 1209 return LookupPropertyValueName(property, value_name, negate, result,
1203 zone()); 1210 zone());
1204 } 1211 }
1205 } 1212 }
1206 1213
1207 #else // V8_I18N_SUPPORT 1214 #else // V8_I18N_SUPPORT
1208 1215
1209 bool RegExpParser::ParsePropertyClass(ZoneList<CharacterRange>* result, 1216 bool RegExpParser::ParsePropertyClass(ZoneList<CharacterRange>* result,
1210 bool negate) { 1217 bool negate) {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 return false; 1794 return false;
1788 } 1795 }
1789 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), 1796 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom),
1790 zone()); 1797 zone());
1791 LAST(ADD_TERM); 1798 LAST(ADD_TERM);
1792 return true; 1799 return true;
1793 } 1800 }
1794 1801
1795 } // namespace internal 1802 } // namespace internal
1796 } // namespace v8 1803 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698