• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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] = {
14   TOKEN_LIST(T, T)
15 };
16 #undef T
17 
18 
19 #define T(name, string, precedence) string,
20 const char* const Token::string_[NUM_TOKENS] = {
21   TOKEN_LIST(T, T)
22 };
23 #undef T
24 
25 #if !V8_CC_MSVC
26 // TODO(vogelheim): Remove #if once MSVC supports constexpr on functions.
27 constexpr
28 #endif
length(const char * str)29 uint8_t length(const char* str) {
30   return str ? static_cast<uint8_t>(strlen(str)) : 0;
31 }
32 #define T(name, string, precedence) length(string),
33 const uint8_t Token::string_length_[NUM_TOKENS] = {TOKEN_LIST(T, T)};
34 #undef T
35 
36 #define T(name, string, precedence) precedence,
37 const int8_t Token::precedence_[NUM_TOKENS] = {
38   TOKEN_LIST(T, T)
39 };
40 #undef T
41 
42 
43 #define KT(a, b, c) 'T',
44 #define KK(a, b, c) 'K',
45 const char Token::token_type[] = {
46   TOKEN_LIST(KT, KK)
47 };
48 #undef KT
49 #undef KK
50 
51 }  // namespace internal
52 }  // namespace v8
53