v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
char-predicates.h
Go to the documentation of this file.
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_STRINGS_CHAR_PREDICATES_H_
6#define V8_STRINGS_CHAR_PREDICATES_H_
7
8#include "src/base/strings.h"
10
11namespace v8 {
12namespace internal {
13
14// Unicode character predicates as defined by ECMA-262, 3rd,
15// used for lexical analysis.
16
17inline constexpr int AsciiAlphaToLower(base::uc32 c);
18inline constexpr bool IsCarriageReturn(base::uc32 c);
19inline constexpr bool IsLineFeed(base::uc32 c);
20inline constexpr bool IsAsciiIdentifier(base::uc32 c);
21inline constexpr bool IsAlphaNumeric(base::uc32 c);
22inline constexpr bool IsDecimalDigit(base::uc32 c);
23inline constexpr bool IsHexDigit(base::uc32 c);
24inline constexpr bool IsOctalDigit(base::uc32 c);
25inline constexpr bool IsBinaryDigit(base::uc32 c);
26inline constexpr bool IsRegExpWord(base::uc32 c);
27
28inline constexpr bool IsAsciiLower(base::uc32 ch);
29inline constexpr bool IsAsciiUpper(base::uc32 ch);
30
31inline constexpr base::uc32 ToAsciiUpper(base::uc32 ch);
32inline constexpr base::uc32 ToAsciiLower(base::uc32 ch);
33
34// ES#sec-names-and-keywords
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'.
39inline bool IsIdentifierStart(base::uc32 c);
40#ifdef V8_INTL_SUPPORT
42#else
43inline bool IsIdentifierStartSlow(base::uc32 c) {
44 // Non-BMP characters are not supported without I18N.
45 return (c <= 0xFFFF) ? unibrow::ID_Start::Is(c) : false;
46}
47#endif
48
49// ES#sec-names-and-keywords
50// This includes \u200c and \u200d, and ID_Continue according to
51// http://www.unicode.org/reports/tr31/, which consists of ID_Start,
52// the categories 'Mn', 'Mc', 'Nd', 'Pc', but excluding properties
53// 'Pattern_Syntax' or 'Pattern_White_Space'.
54inline bool IsIdentifierPart(base::uc32 c);
55#ifdef V8_INTL_SUPPORT
57#else
58inline bool IsIdentifierPartSlow(base::uc32 c) {
59 // Non-BMP charaacters are not supported without I18N.
60 if (c <= 0xFFFF) {
62 }
63 return false;
64}
65#endif
66
67// ES6 draft section 11.2
68// This includes all code points of Unicode category 'Zs'.
69// Further included are \u0009, \u000b, \u000c, and \ufeff.
70inline bool IsWhiteSpace(base::uc32 c);
71#ifdef V8_INTL_SUPPORT
73#else
74inline bool IsWhiteSpaceSlow(base::uc32 c) {
76}
77#endif
78
79// WhiteSpace and LineTerminator according to ES6 draft section 11.2 and 11.3
80// This includes all the characters with Unicode category 'Z' (= Zs+Zl+Zp)
81// as well as \u0009 - \u000d and \ufeff.
86
88
89} // namespace internal
90} // namespace v8
91
92#endif // V8_STRINGS_CHAR_PREDICATES_H_
V8_INLINE bool IsLineTerminator(uchar c)
Definition unicode.h:267
uint32_t uc32
Definition strings.h:19
bool IsIdentifierStart(base::uc32 c)
constexpr bool IsHexDigit(base::uc32 c)
bool IsLineTerminatorSequence(base::uc32 c, base::uc32 next)
constexpr bool IsAsciiIdentifier(base::uc32 c)
constexpr bool IsCarriageReturn(base::uc32 c)
constexpr bool IsAsciiLower(base::uc32 c)
bool IsWhiteSpaceOrLineTerminator(base::uc32 c)
constexpr bool IsOctalDigit(base::uc32 c)
bool IsIdentifierPartSlow(base::uc32 c)
bool IsWhiteSpace(base::uc32 c)
constexpr bool IsRegExpWord(base::uc32 c)
constexpr bool IsDecimalDigit(base::uc32 c)
bool IsWhiteSpaceOrLineTerminatorSlow(base::uc32 c)
constexpr base::uc32 ToAsciiUpper(base::uc32 c)
constexpr bool IsAsciiUpper(base::uc32 c)
constexpr bool IsBinaryDigit(base::uc32 c)
constexpr bool IsLineFeed(base::uc32 c)
constexpr int AsciiAlphaToLower(base::uc32 c)
constexpr bool IsAlphaNumeric(base::uc32 c)
bool IsIdentifierStartSlow(base::uc32 c)
bool IsWhiteSpaceSlow(base::uc32 c)
bool IsIdentifierPart(base::uc32 c)
constexpr base::uc32 ToAsciiLower(base::uc32 c)
#define V8_EXPORT_PRIVATE
Definition macros.h:460
static bool Is(uchar c)
Definition unicode.cc:849
static bool Is(uchar c)
Definition unicode.cc:743
static bool Is(uchar c)
Definition unicode.cc:874