11cb0ef41Sopenharmony_ci// Copyright 2011 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_INTL_SUPPORT
61cb0ef41Sopenharmony_ci#error Internationalization is expected to be enabled.
71cb0ef41Sopenharmony_ci#endif  // V8_INTL_SUPPORT
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci#include "src/strings/char-predicates.h"
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci#include "unicode/uchar.h"
121cb0ef41Sopenharmony_ci#include "unicode/urename.h"
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cinamespace v8 {
151cb0ef41Sopenharmony_cinamespace internal {
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci// ES#sec-names-and-keywords Names and Keywords
181cb0ef41Sopenharmony_ci// UnicodeIDStart, '$', '_' and '\'
191cb0ef41Sopenharmony_cibool IsIdentifierStartSlow(base::uc32 c) {
201cb0ef41Sopenharmony_ci  // cannot use u_isIDStart because it does not work for
211cb0ef41Sopenharmony_ci  // Other_ID_Start characters.
221cb0ef41Sopenharmony_ci  return u_hasBinaryProperty(c, UCHAR_ID_START) ||
231cb0ef41Sopenharmony_ci         (c < 0x60 && (c == '$' || c == '\\' || c == '_'));
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci// ES#sec-names-and-keywords Names and Keywords
271cb0ef41Sopenharmony_ci// UnicodeIDContinue, '$', '_', '\', ZWJ, and ZWNJ
281cb0ef41Sopenharmony_cibool IsIdentifierPartSlow(base::uc32 c) {
291cb0ef41Sopenharmony_ci  // Can't use u_isIDPart because it does not work for
301cb0ef41Sopenharmony_ci  // Other_ID_Continue characters.
311cb0ef41Sopenharmony_ci  return u_hasBinaryProperty(c, UCHAR_ID_CONTINUE) ||
321cb0ef41Sopenharmony_ci         (c < 0x60 && (c == '$' || c == '\\' || c == '_')) || c == 0x200C ||
331cb0ef41Sopenharmony_ci         c == 0x200D;
341cb0ef41Sopenharmony_ci}
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci// ES#sec-white-space White Space
371cb0ef41Sopenharmony_ci// gC=Zs, U+0009, U+000B, U+000C, U+FEFF
381cb0ef41Sopenharmony_cibool IsWhiteSpaceSlow(base::uc32 c) {
391cb0ef41Sopenharmony_ci  return (u_charType(c) == U_SPACE_SEPARATOR) ||
401cb0ef41Sopenharmony_ci         (c < 0x0D && (c == 0x09 || c == 0x0B || c == 0x0C)) || c == 0xFEFF;
411cb0ef41Sopenharmony_ci}
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ci}  // namespace internal
441cb0ef41Sopenharmony_ci}  // namespace v8
45