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
3 // found in the LICENSE file.
4
5 #ifndef V8_INTL_SUPPORT
6 #error Internationalization is expected to be enabled.
7 #endif // V8_INTL_SUPPORT
8
9 #include "src/strings/char-predicates.h"
10
11 #include "unicode/uchar.h"
12 #include "unicode/urename.h"
13
14 namespace v8 {
15 namespace internal {
16
17 // ES#sec-names-and-keywords Names and Keywords
18 // UnicodeIDStart, '$', '_' and '\'
IsIdentifierStartSlow(base::uc32 c)19 bool IsIdentifierStartSlow(base::uc32 c) {
20 // cannot use u_isIDStart because it does not work for
21 // Other_ID_Start characters.
22 return u_hasBinaryProperty(c, UCHAR_ID_START) ||
23 (c < 0x60 && (c == '$' || c == '\\' || c == '_'));
24 }
25
26 // ES#sec-names-and-keywords Names and Keywords
27 // UnicodeIDContinue, '$', '_', '\', ZWJ, and ZWNJ
IsIdentifierPartSlow(base::uc32 c)28 bool IsIdentifierPartSlow(base::uc32 c) {
29 // Can't use u_isIDPart because it does not work for
30 // Other_ID_Continue characters.
31 return u_hasBinaryProperty(c, UCHAR_ID_CONTINUE) ||
32 (c < 0x60 && (c == '$' || c == '\\' || c == '_')) || c == 0x200C ||
33 c == 0x200D;
34 }
35
36 // ES#sec-white-space White Space
37 // gC=Zs, U+0009, U+000B, U+000C, U+FEFF
IsWhiteSpaceSlow(base::uc32 c)38 bool IsWhiteSpaceSlow(base::uc32 c) {
39 return (u_charType(c) == U_SPACE_SEPARATOR) ||
40 (c < 0x0D && (c == 0x09 || c == 0x0B || c == 0x0C)) || c == 0xFEFF;
41 }
42
43 } // namespace internal
44 } // namespace v8
45