| 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_PARSING_TOKEN_H_ | 5 #ifndef V8_PARSING_TOKEN_H_ |
| 6 #define V8_PARSING_TOKEN_H_ | 6 #define V8_PARSING_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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 DCHECK(tok < NUM_TOKENS); // tok is unsigned | 193 DCHECK(tok < NUM_TOKENS); // tok is unsigned |
| 194 return name_[tok]; | 194 return name_[tok]; |
| 195 } | 195 } |
| 196 | 196 |
| 197 // Predicates | 197 // Predicates |
| 198 static bool IsKeyword(Value tok) { | 198 static bool IsKeyword(Value tok) { |
| 199 return token_type[tok] == 'K'; | 199 return token_type[tok] == 'K'; |
| 200 } | 200 } |
| 201 | 201 |
| 202 static bool IsIdentifier(Value tok, LanguageMode language_mode, | 202 static bool IsIdentifier(Value tok, LanguageMode language_mode, |
| 203 bool is_generator, bool is_module) { | 203 bool is_generator, bool disallow_await) { |
| 204 switch (tok) { | 204 switch (tok) { |
| 205 case IDENTIFIER: | 205 case IDENTIFIER: |
| 206 case ASYNC: | 206 case ASYNC: |
| 207 return true; | 207 return true; |
| 208 case ESCAPED_STRICT_RESERVED_WORD: | 208 case ESCAPED_STRICT_RESERVED_WORD: |
| 209 case FUTURE_STRICT_RESERVED_WORD: | 209 case FUTURE_STRICT_RESERVED_WORD: |
| 210 case LET: | 210 case LET: |
| 211 case STATIC: | 211 case STATIC: |
| 212 return is_sloppy(language_mode); | 212 return is_sloppy(language_mode); |
| 213 case YIELD: | 213 case YIELD: |
| 214 return !is_generator && is_sloppy(language_mode); | 214 return !is_generator && is_sloppy(language_mode); |
| 215 case AWAIT: | 215 case AWAIT: |
| 216 return !is_module; | 216 return !disallow_await; |
| 217 default: | 217 default: |
| 218 return false; | 218 return false; |
| 219 } | 219 } |
| 220 UNREACHABLE(); | 220 UNREACHABLE(); |
| 221 return false; | 221 return false; |
| 222 } | 222 } |
| 223 | 223 |
| 224 static bool IsAssignmentOp(Value tok) { | 224 static bool IsAssignmentOp(Value tok) { |
| 225 return INIT <= tok && tok <= ASSIGN_EXP; | 225 return INIT <= tok && tok <= ASSIGN_EXP; |
| 226 } | 226 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 static const char* const string_[NUM_TOKENS]; | 343 static const char* const string_[NUM_TOKENS]; |
| 344 static const uint8_t string_length_[NUM_TOKENS]; | 344 static const uint8_t string_length_[NUM_TOKENS]; |
| 345 static const int8_t precedence_[NUM_TOKENS]; | 345 static const int8_t precedence_[NUM_TOKENS]; |
| 346 static const char token_type[NUM_TOKENS]; | 346 static const char token_type[NUM_TOKENS]; |
| 347 }; | 347 }; |
| 348 | 348 |
| 349 } // namespace internal | 349 } // namespace internal |
| 350 } // namespace v8 | 350 } // namespace v8 |
| 351 | 351 |
| 352 #endif // V8_PARSING_TOKEN_H_ | 352 #endif // V8_PARSING_TOKEN_H_ |
| OLD | NEW |