| 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 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // Scanner | 33 // Scanner |
| 34 | 34 |
| 35 Scanner::Scanner(UnicodeCache* unicode_cache) | 35 Scanner::Scanner(UnicodeCache* unicode_cache) |
| 36 : unicode_cache_(unicode_cache), | 36 : unicode_cache_(unicode_cache), |
| 37 octal_pos_(Location::invalid()), | 37 octal_pos_(Location::invalid()), |
| 38 harmony_scoping_(false), | 38 harmony_scoping_(false), |
| 39 harmony_modules_(false), | 39 harmony_modules_(false), |
| 40 harmony_numeric_literals_(false), | 40 harmony_numeric_literals_(false), |
| 41 harmony_classes_(false), | 41 harmony_classes_(false), |
| 42 harmony_templates_(false), | 42 harmony_templates_(false), |
| 43 harmony_unicode_(false) {} | 43 harmony_unicode_(false), |
| 44 harmony_exponentiation_(false) {} |
| 44 | 45 |
| 45 | 46 |
| 46 void Scanner::Initialize(Utf16CharacterStream* source) { | 47 void Scanner::Initialize(Utf16CharacterStream* source) { |
| 47 source_ = source; | 48 source_ = source; |
| 48 // Need to capture identifiers in order to recognize "get" and "set" | 49 // Need to capture identifiers in order to recognize "get" and "set" |
| 49 // in object literals. | 50 // in object literals. |
| 50 Init(); | 51 Init(); |
| 51 // Skip initial whitespace allowing HTML comment ends just like | 52 // Skip initial whitespace allowing HTML comment ends just like |
| 52 // after a newline and scan first token. | 53 // after a newline and scan first token. |
| 53 has_line_terminator_before_next_ = true; | 54 has_line_terminator_before_next_ = true; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 token = Token::DEC; | 527 token = Token::DEC; |
| 527 } | 528 } |
| 528 } else if (c0_ == '=') { | 529 } else if (c0_ == '=') { |
| 529 token = Select(Token::ASSIGN_SUB); | 530 token = Select(Token::ASSIGN_SUB); |
| 530 } else { | 531 } else { |
| 531 token = Token::SUB; | 532 token = Token::SUB; |
| 532 } | 533 } |
| 533 break; | 534 break; |
| 534 | 535 |
| 535 case '*': | 536 case '*': |
| 536 // * *= | 537 // * *= ** **= |
| 537 token = Select('=', Token::ASSIGN_MUL, Token::MUL); | 538 Advance(); |
| 539 if (c0_ == '*') { |
| 540 if (HarmonyExponentiation()) { |
| 541 token = Select('=', Token::ASSIGN_EXP, Token::EXP); |
| 542 } else { |
| 543 token = Token::ILLEGAL; |
| 544 } |
| 545 } else if (c0_ == '=') { |
| 546 token = Select(Token::ASSIGN_MUL); |
| 547 } else { |
| 548 token = Token::MUL; |
| 549 } |
| 538 break; | 550 break; |
| 539 | 551 |
| 540 case '%': | 552 case '%': |
| 541 // % %= | 553 // % %= |
| 542 token = Select('=', Token::ASSIGN_MOD, Token::MOD); | 554 token = Select('=', Token::ASSIGN_MOD, Token::MOD); |
| 543 break; | 555 break; |
| 544 | 556 |
| 545 case '/': | 557 case '/': |
| 546 // / // /* /= | 558 // / // /* /= |
| 547 Advance(); | 559 Advance(); |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1487 } | 1499 } |
| 1488 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1500 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
| 1489 } | 1501 } |
| 1490 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1502 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
| 1491 | 1503 |
| 1492 backing_store_.AddBlock(bytes); | 1504 backing_store_.AddBlock(bytes); |
| 1493 return backing_store_.EndSequence().start(); | 1505 return backing_store_.EndSequence().start(); |
| 1494 } | 1506 } |
| 1495 | 1507 |
| 1496 } } // namespace v8::internal | 1508 } } // namespace v8::internal |
| OLD | NEW |