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.
5 #ifndef V8_CHAR_PREDICATES_H_
6 #define V8_CHAR_PREDICATES_H_
13 // Unicode character predicates as defined by ECMA-262, 3rd,
14 // used for lexical analysis.
16 inline bool IsCarriageReturn(uc32 c);
17 inline bool IsLineFeed(uc32 c);
18 inline bool IsDecimalDigit(uc32 c);
19 inline bool IsHexDigit(uc32 c);
20 inline bool IsOctalDigit(uc32 c);
21 inline bool IsBinaryDigit(uc32 c);
22 inline bool IsRegExpWord(uc32 c);
23 inline bool IsRegExpNewline(uc32 c);
25 struct IdentifierStart {
26 static inline bool Is(uc32 c) {
28 case '$': case '_': case '\\': return true;
29 default: return unibrow::Letter::Is(c);
35 struct IdentifierPart {
36 static inline bool Is(uc32 c) {
37 return IdentifierStart::Is(c)
38 || unibrow::Number::Is(c)
39 || c == 0x200C // U+200C is Zero-Width Non-Joiner.
40 || c == 0x200D // U+200D is Zero-Width Joiner.
41 || unibrow::CombiningMark::Is(c)
42 || unibrow::ConnectorPunctuation::Is(c);
47 // WhiteSpace according to ECMA-262 5.1, 7.2.
49 static inline bool Is(uc32 c) {
50 return c == 0x0009 || // <TAB>
51 c == 0x000B || // <VT>
52 c == 0x000C || // <FF>
53 c == 0xFEFF || // <BOM>
54 // \u0020 and \u00A0 are included in unibrow::WhiteSpace.
55 unibrow::WhiteSpace::Is(c);
60 // WhiteSpace and LineTerminator according to ECMA-262 5.1, 7.2 and 7.3.
61 struct WhiteSpaceOrLineTerminator {
62 static inline bool Is(uc32 c) {
63 return WhiteSpace::Is(c) || unibrow::LineTerminator::Is(c);
67 } } // namespace v8::internal
69 #endif // V8_CHAR_PREDICATES_H_