V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
token.cc
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 
9 namespace v8 {
10 namespace internal {
11 
12 #define T(name, string, precedence) #name,
13 const char* const Token::name_[NUM_TOKENS] = {TOKEN_LIST(T, T, T)};
14 #undef T
15 
16 
17 #define T(name, string, precedence) string,
18 const char* const Token::string_[NUM_TOKENS] = {TOKEN_LIST(T, T, T)};
19 #undef T
20 
21 constexpr 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),
25 const uint8_t Token::string_length_[NUM_TOKENS] = {TOKEN_LIST(T, T, T)};
26 #undef T
27 
28 #define T1(name, string, precedence) \
29  ((Token::name == Token::IN) ? 0 : precedence),
30 #define T2(name, string, precedence) precedence,
31 // precedence_[0] for accept_IN == false, precedence_[1] for accept_IN = true.
32 const int8_t Token::precedence_[2][NUM_TOKENS] = {{TOKEN_LIST(T1, T1, T1)},
33  {TOKEN_LIST(T2, T2, T2)}};
34 #undef T2
35 #undef T1
36 
37 #define KT(a, b, c) 'T',
38 #define KK(a, b, c) 'K',
39 #define KC(a, b, c) 'C',
40 const char Token::token_type[] = {TOKEN_LIST(KT, KK, KC)};
41 #undef KT
42 #undef KK
43 #undef KC
44 
45 } // namespace internal
46 } // namespace v8
Definition: libplatform.h:13