Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: src/scanner.cc

Issue 953563002: Implement experimental exponentiation operator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: use Number() instead of OrderedNumber() to include NaN Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | src/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698