OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #ifndef V8_SCANNER_H_ | 7 #ifndef V8_SCANNER_H_ |
8 #define V8_SCANNER_H_ | 8 #define V8_SCANNER_H_ |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 377 } |
378 bool is_next_contextual_keyword(Vector<const char> keyword) { | 378 bool is_next_contextual_keyword(Vector<const char> keyword) { |
379 DCHECK_NOT_NULL(next_.literal_chars); | 379 DCHECK_NOT_NULL(next_.literal_chars); |
380 return next_.literal_chars->is_contextual_keyword(keyword); | 380 return next_.literal_chars->is_contextual_keyword(keyword); |
381 } | 381 } |
382 | 382 |
383 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); | 383 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); |
384 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); | 384 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); |
385 | 385 |
386 double DoubleValue(); | 386 double DoubleValue(); |
387 bool UnescapedLiteralMatches(const char* data, int length) { | 387 bool LiteralMatches(const char* data, int length, bool allow_escapes = true) { |
388 if (is_literal_one_byte() && | 388 if (is_literal_one_byte() && |
389 literal_length() == length && | 389 literal_length() == length && |
390 !literal_contains_escapes()) { | 390 (allow_escapes || !literal_contains_escapes())) { |
391 const char* token = | 391 const char* token = |
392 reinterpret_cast<const char*>(literal_one_byte_string().start()); | 392 reinterpret_cast<const char*>(literal_one_byte_string().start()); |
393 return !strncmp(token, data, length); | 393 return !strncmp(token, data, length); |
394 } | 394 } |
395 return false; | 395 return false; |
396 } | 396 } |
| 397 inline bool UnescapedLiteralMatches(const char* data, int length) { |
| 398 return LiteralMatches(data, length, false); |
| 399 } |
| 400 |
397 void IsGetOrSet(bool* is_get, bool* is_set) { | 401 void IsGetOrSet(bool* is_get, bool* is_set) { |
398 if (is_literal_one_byte() && | 402 if (is_literal_one_byte() && |
399 literal_length() == 3 && | 403 literal_length() == 3 && |
400 !literal_contains_escapes()) { | 404 !literal_contains_escapes()) { |
401 const char* token = | 405 const char* token = |
402 reinterpret_cast<const char*>(literal_one_byte_string().start()); | 406 reinterpret_cast<const char*>(literal_one_byte_string().start()); |
403 *is_get = strncmp(token, "get", 3) == 0; | 407 *is_get = strncmp(token, "get", 3) == 0; |
404 *is_set = !*is_get && strncmp(token, "set", 3) == 0; | 408 *is_set = !*is_get && strncmp(token, "set", 3) == 0; |
405 } | 409 } |
406 } | 410 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 bool harmony_modules_; | 657 bool harmony_modules_; |
654 // Whether we scan 0o777 and 0b111 as numbers. | 658 // Whether we scan 0o777 and 0b111 as numbers. |
655 bool harmony_numeric_literals_; | 659 bool harmony_numeric_literals_; |
656 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. | 660 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. |
657 bool harmony_classes_; | 661 bool harmony_classes_; |
658 }; | 662 }; |
659 | 663 |
660 } } // namespace v8::internal | 664 } } // namespace v8::internal |
661 | 665 |
662 #endif // V8_SCANNER_H_ | 666 #endif // V8_SCANNER_H_ |
OLD | NEW |