OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #ifdef V8_INTL_SUPPORT |
5 #include "src/char-predicates.h" | 6 #include "src/char-predicates.h" |
6 | 7 |
7 #ifdef V8_INTL_SUPPORT | |
8 #include "unicode/uchar.h" | 8 #include "unicode/uchar.h" |
9 #include "unicode/urename.h" | 9 #include "unicode/urename.h" |
10 #endif // V8_INTL_SUPPORT | |
11 | 10 |
12 namespace v8 { | 11 namespace v8 { |
13 namespace internal { | 12 namespace internal { |
14 | 13 |
15 bool SupplementaryPlanes::IsIDStart(uc32 c) { | 14 bool IdentifierStart::Is(uc32 c) { |
16 DCHECK(c > 0xFFFF); | 15 // cannot use u_isIDStart because it does not work for |
17 #ifdef V8_INTL_SUPPORT | 16 // Other_ID_Start characters. |
18 // This only works for code points in the SMPs, since ICU does not exclude | 17 return u_hasBinaryProperty(c, UCHAR_ID_START) || |
19 // code points with properties 'Pattern_Syntax' or 'Pattern_White_Space'. | 18 (c < 0x60 && (c == 0x24 || c == 0x5C || c == 0x5F)); |
20 // Code points in the SMP do not have those properties. | |
21 return u_isIDStart(c); | |
22 #else | |
23 // This is incorrect, but if we don't have ICU, use this as fallback. | |
24 return false; | |
25 #endif // V8_INTL_SUPPORT | |
26 } | 19 } |
27 | 20 |
| 21 bool IdentifierPart::Is(uc32 c) { |
| 22 // Can't use u_isIDPart because it does not work for |
| 23 // Other_ID_Continue characters. |
| 24 return u_hasBinaryProperty(c, UCHAR_ID_CONTINUE) || |
| 25 (c < 0x60 && (c == 0x24 || c == 0x5C || c == 0x5F)) || c == 0x200C || |
| 26 c == 0x200D; |
| 27 } |
28 | 28 |
29 bool SupplementaryPlanes::IsIDPart(uc32 c) { | 29 // Ecma 262 7.0 11.2 White Space |
30 DCHECK(c > 0xFFFF); | 30 // gC=Zs, U+0009, U+000B, U+000C, U+FEFF |
31 #ifdef V8_INTL_SUPPORT | 31 bool WhiteSpace::Is(uc32 c) { |
32 // This only works for code points in the SMPs, since ICU does not exclude | 32 return (u_charType(c) == U_SPACE_SEPARATOR) || |
33 // code points with properties 'Pattern_Syntax' or 'Pattern_White_Space'. | 33 (c < 0x0D && (c == 0x09 || c == 0x0B || c == 0x0C)) || c == 0xFEFF; |
34 // Code points in the SMP do not have those properties. | |
35 return u_isIDPart(c); | |
36 #else | |
37 // This is incorrect, but if we don't have ICU, use this as fallback. | |
38 return false; | |
39 #endif // V8_INTL_SUPPORT | |
40 } | 34 } |
| 35 |
41 } // namespace internal | 36 } // namespace internal |
42 } // namespace v8 | 37 } // namespace v8 |
| 38 #endif // V8_INTL_SUPPORT |
OLD | NEW |