| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_TOKEN_H_ | 5 #ifndef V8_TOKEN_H_ |
| 6 #define V8_TOKEN_H_ | 6 #define V8_TOKEN_H_ |
| 7 | 7 |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/globals.h" | 9 #include "src/globals.h" |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 K(CLASS, "class", 0) \ | 154 K(CLASS, "class", 0) \ |
| 155 K(CONST, "const", 0) \ | 155 K(CONST, "const", 0) \ |
| 156 K(EXPORT, "export", 0) \ | 156 K(EXPORT, "export", 0) \ |
| 157 K(EXTENDS, "extends", 0) \ | 157 K(EXTENDS, "extends", 0) \ |
| 158 K(IMPORT, "import", 0) \ | 158 K(IMPORT, "import", 0) \ |
| 159 K(LET, "let", 0) \ | 159 K(LET, "let", 0) \ |
| 160 K(STATIC, "static", 0) \ | 160 K(STATIC, "static", 0) \ |
| 161 K(YIELD, "yield", 0) \ | 161 K(YIELD, "yield", 0) \ |
| 162 K(SUPER, "super", 0) \ | 162 K(SUPER, "super", 0) \ |
| 163 \ | 163 \ |
| 164 /* Async await */ \ |
| 165 K(ASYNC, "async", 0) \ |
| 166 \ |
| 164 /* Illegal token - not able to scan. */ \ | 167 /* Illegal token - not able to scan. */ \ |
| 165 T(ILLEGAL, "ILLEGAL", 0) \ | 168 T(ILLEGAL, "ILLEGAL", 0) \ |
| 166 \ | 169 \ |
| 167 /* Scanner-internal use only. */ \ | 170 /* Scanner-internal use only. */ \ |
| 168 T(WHITESPACE, NULL, 0) \ | 171 T(WHITESPACE, NULL, 0) \ |
| 169 T(UNINITIALIZED, NULL, 0) \ | 172 T(UNINITIALIZED, NULL, 0) \ |
| 170 \ | 173 \ |
| 171 /* ES6 Template Literals */ \ | 174 /* ES6 Template Literals */ \ |
| 172 T(TEMPLATE_SPAN, NULL, 0) \ | 175 T(TEMPLATE_SPAN, NULL, 0) \ |
| 173 T(TEMPLATE_TAIL, NULL, 0) | 176 T(TEMPLATE_TAIL, NULL, 0) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 192 | 195 |
| 193 // Predicates | 196 // Predicates |
| 194 static bool IsKeyword(Value tok) { | 197 static bool IsKeyword(Value tok) { |
| 195 return token_type[tok] == 'K'; | 198 return token_type[tok] == 'K'; |
| 196 } | 199 } |
| 197 | 200 |
| 198 static bool IsIdentifier(Value tok, LanguageMode language_mode, | 201 static bool IsIdentifier(Value tok, LanguageMode language_mode, |
| 199 bool is_generator) { | 202 bool is_generator) { |
| 200 switch (tok) { | 203 switch (tok) { |
| 201 case IDENTIFIER: | 204 case IDENTIFIER: |
| 205 case ASYNC: |
| 202 return true; | 206 return true; |
| 203 case FUTURE_STRICT_RESERVED_WORD: | 207 case FUTURE_STRICT_RESERVED_WORD: |
| 204 case LET: | 208 case LET: |
| 205 case STATIC: | 209 case STATIC: |
| 206 return is_sloppy(language_mode); | 210 return is_sloppy(language_mode); |
| 207 case YIELD: | 211 case YIELD: |
| 208 return !is_generator && is_sloppy(language_mode); | 212 return !is_generator && is_sloppy(language_mode); |
| 209 default: | 213 default: |
| 210 return false; | 214 return false; |
| 211 } | 215 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 static const char* const name_[NUM_TOKENS]; | 319 static const char* const name_[NUM_TOKENS]; |
| 316 static const char* const string_[NUM_TOKENS]; | 320 static const char* const string_[NUM_TOKENS]; |
| 317 static const int8_t precedence_[NUM_TOKENS]; | 321 static const int8_t precedence_[NUM_TOKENS]; |
| 318 static const char token_type[NUM_TOKENS]; | 322 static const char token_type[NUM_TOKENS]; |
| 319 }; | 323 }; |
| 320 | 324 |
| 321 } // namespace internal | 325 } // namespace internal |
| 322 } // namespace v8 | 326 } // namespace v8 |
| 323 | 327 |
| 324 #endif // V8_TOKEN_H_ | 328 #endif // V8_TOKEN_H_ |
| OLD | NEW |