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

Side by Side Diff: runtime/vm/scanner.cc

Issue 17103002: Remove support for + prefix in number literals (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/scanner_test.cc » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/scanner.h" 5 #include "vm/scanner.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 bool* is_positive, 182 bool* is_positive,
183 String** value) { 183 String** value) {
184 if ((tokens.length() == 2) && 184 if ((tokens.length() == 2) &&
185 (tokens[0].kind == literal_kind) && 185 (tokens[0].kind == literal_kind) &&
186 (tokens[1].kind == Token::kEOS)) { 186 (tokens[1].kind == Token::kEOS)) {
187 *is_positive = true; 187 *is_positive = true;
188 *value = tokens[0].literal; 188 *value = tokens[0].literal;
189 return true; 189 return true;
190 } 190 }
191 if ((tokens.length() == 3) && 191 if ((tokens.length() == 3) &&
192 ((tokens[0].kind == Token::kTIGHTADD) || 192 ((tokens[0].kind == Token::kADD) ||
193 (tokens[0].kind == Token::kSUB)) && 193 (tokens[0].kind == Token::kSUB)) &&
194 (tokens[1].kind == literal_kind) && 194 (tokens[1].kind == literal_kind) &&
195 (tokens[2].kind == Token::kEOS)) { 195 (tokens[2].kind == Token::kEOS)) {
196 // Check there is no space between "+/-" and number. 196 // Check there is no space between "+/-" and number.
197 if ((tokens[0].offset + 1) != tokens[1].offset) { 197 if ((tokens[0].offset + 1) != tokens[1].offset) {
198 return false; 198 return false;
199 } 199 }
200 *is_positive = tokens[0].kind == Token::kTIGHTADD; 200 *is_positive = tokens[0].kind == Token::kADD;
201 *value = tokens[1].literal; 201 *value = tokens[1].literal;
202 return true; 202 return true;
203 } 203 }
204 return false; 204 return false;
205 } 205 }
206 206
207 207
208 void Scanner::ReadChar() { 208 void Scanner::ReadChar() {
209 if (lookahead_pos_ < source_length_) { 209 if (lookahead_pos_ < source_length_) {
210 if (c0_ == '\n') { 210 if (c0_ == '\n') {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 ScanLiteralStringChars(false); 632 ScanLiteralStringChars(false);
633 } 633 }
634 break; 634 break;
635 } 635 }
636 switch (c0_) { 636 switch (c0_) {
637 case '\0': 637 case '\0':
638 current_token_.kind = Token::kEOS; 638 current_token_.kind = Token::kEOS;
639 break; 639 break;
640 640
641 case '+': // + ++ += 641 case '+': // + ++ +=
642 ReadChar(); 642 Recognize(Token::kADD);
643 current_token_.kind = 643 if (c0_ == '+') {
644 IsNumberStart(c0_) ? Token::kTIGHTADD : Token::kADD;
645 // Unary + is not allowed for hexadecimal integers, so treat the
646 // + as a binary operator.
647 if ((c0_ == '0') &&
648 ((LookaheadChar(1) == 'x') || (LookaheadChar(1) == 'X'))) {
649 current_token_.kind = Token::kADD;
650 } else if (c0_ == '+') {
651 Recognize(Token::kINCR); 644 Recognize(Token::kINCR);
652 } else if (c0_ == '=') { 645 } else if (c0_ == '=') {
653 Recognize(Token::kASSIGN_ADD); 646 Recognize(Token::kASSIGN_ADD);
654 } 647 }
655 break; 648 break;
656 649
657 case '-': // - -- -= 650 case '-': // - -- -=
658 Recognize(Token::kSUB); 651 Recognize(Token::kSUB);
659 if (c0_ == '-') { 652 if (c0_ == '-') {
660 Recognize(Token::kDECR); 653 Recognize(Token::kDECR);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 "%c%#"Px"", kPrivateKeySeparator, key_value); 954 "%c%#"Px"", kPrivateKeySeparator, key_value);
962 const String& result = String::Handle(String::New(private_key, Heap::kOld)); 955 const String& result = String::Handle(String::New(private_key, Heap::kOld));
963 return result.raw(); 956 return result.raw();
964 } 957 }
965 958
966 959
967 void Scanner::InitOnce() { 960 void Scanner::InitOnce() {
968 } 961 }
969 962
970 } // namespace dart 963 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/scanner_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698