v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
token.cc
Go to the documentation of this file.
1// Copyright 2006-2008 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#include <stdint.h>
6
7#include "src/parsing/token.h"
8
9namespace v8 {
10namespace internal {
11
12#define T(name, string, precedence) #name,
13const char* const Token::name_[kNumTokens] = {TOKEN_LIST(T, T)};
14#undef T
15
16
17#define T(name, string, precedence) string,
18const char* const Token::string_[kNumTokens] = {TOKEN_LIST(T, T)};
19#undef T
20
21constexpr uint8_t length(const char* str) {
22 return str ? static_cast<uint8_t>(strlen(str)) : 0;
23}
24#define T(name, string, precedence) length(string),
25const uint8_t Token::string_length_[kNumTokens] = {TOKEN_LIST(T, T)};
26#undef T
27
28#define T1(name, string, precedence) \
29 ((Token::name == Token::kIn) ? 0 : precedence),
30#define T2(name, string, precedence) precedence,
31// precedence_[0] for accept_IN == false, precedence_[1] for accept_IN = true.
32const int8_t Token::precedence_[2][kNumTokens] = {{TOKEN_LIST(T1, T1)},
33 {TOKEN_LIST(T2, T2)}};
34#undef T2
35#undef T1
36
37#define KT(a, b, c) \
38 IsPropertyNameBits::encode(Token::IsAnyIdentifier(a) || a == kEscapedKeyword),
39#define KK(a, b, c) \
40 IsKeywordBits::encode(true) | IsPropertyNameBits::encode(true),
41const uint8_t Token::token_flags[] = {TOKEN_LIST(KT, KK)};
42#undef KT
43#undef KK
44
45} // namespace internal
46} // namespace v8
static const uint8_t token_flags[kNumTokens]
Definition token.h:350
static const char *const string_[kNumTokens]
Definition token.h:347
static const char *const name_[kNumTokens]
Definition token.h:346
static const uint8_t string_length_[kNumTokens]
Definition token.h:348
static const int8_t precedence_[2][kNumTokens]
Definition token.h:349
#define T1(name, string, precedence)
Definition token.cc:28
#define KK(a, b, c)
Definition token.cc:39
#define KT(a, b, c)
Definition token.cc:37
#define T2(name, string, precedence)
Definition token.cc:30
#define TOKEN_LIST(T, K)
Definition token.h:56