deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / src / char-predicates.h
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_CHAR_PREDICATES_H_
6 #define V8_CHAR_PREDICATES_H_
7
8 #include "src/unicode.h"
9
10 namespace v8 {
11 namespace internal {
12
13 // Unicode character predicates as defined by ECMA-262, 3rd,
14 // used for lexical analysis.
15
16 inline bool IsCarriageReturn(uc32 c);
17 inline bool IsLineFeed(uc32 c);
18 inline bool IsAsciiIdentifier(uc32 c);
19 inline bool IsAlphaNumeric(uc32 c);
20 inline bool IsDecimalDigit(uc32 c);
21 inline bool IsHexDigit(uc32 c);
22 inline bool IsOctalDigit(uc32 c);
23 inline bool IsBinaryDigit(uc32 c);
24 inline bool IsRegExpWord(uc32 c);
25 inline bool IsRegExpNewline(uc32 c);
26
27
28 struct SupplementaryPlanes {
29   static bool IsIDStart(uc32 c);
30   static bool IsIDPart(uc32 c);
31 };
32
33
34 // ES6 draft section 11.6
35 // This includes '_', '$' and '\', and ID_Start according to
36 // http://www.unicode.org/reports/tr31/, which consists of categories
37 // 'Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', but excluding properties
38 // 'Pattern_Syntax' or 'Pattern_White_Space'.
39 // For code points in the SMPs, we can resort to ICU (if available).
40 struct IdentifierStart {
41   static inline bool Is(uc32 c) {
42     if (c > 0xFFFF) return SupplementaryPlanes::IsIDStart(c);
43     return unibrow::ID_Start::Is(c);
44   }
45 };
46
47
48 // ES6 draft section 11.6
49 // This includes \u200c and \u200d, and ID_Continue according to
50 // http://www.unicode.org/reports/tr31/, which consists of ID_Start,
51 // the categories 'Mn', 'Mc', 'Nd', 'Pc', but excluding properties
52 // 'Pattern_Syntax' or 'Pattern_White_Space'.
53 // For code points in the SMPs, we can resort to ICU (if available).
54 struct IdentifierPart {
55   static inline bool Is(uc32 c) {
56     if (c > 0xFFFF) return SupplementaryPlanes::IsIDPart(c);
57     return unibrow::ID_Start::Is(c) || unibrow::ID_Continue::Is(c);
58   }
59 };
60
61
62 // ES6 draft section 11.2
63 // This includes all code points of Unicode category 'Zs'.
64 // \u180e stops being one as of Unicode 6.3.0, but ES6 adheres to Unicode 5.1,
65 // so it is also included.
66 // Further included are \u0009, \u000b, \u0020, \u00a0, \u000c, and \ufeff.
67 // There are no category 'Zs' code points in the SMPs.
68 struct WhiteSpace {
69   static inline bool Is(uc32 c) { return unibrow::WhiteSpace::Is(c); }
70 };
71
72
73 // WhiteSpace and LineTerminator according to ES6 draft section 11.2 and 11.3
74 // This consists of \000a, \000d, \u2028, and \u2029.
75 struct WhiteSpaceOrLineTerminator {
76   static inline bool Is(uc32 c) {
77     return WhiteSpace::Is(c) || unibrow::LineTerminator::Is(c);
78   }
79 };
80
81 } }  // namespace v8::internal
82
83 #endif  // V8_CHAR_PREDICATES_H_