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

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

Issue 9264051: Fix for bug 1229: Unary operator plus is not allowed ... except for literals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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
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/thread.h" 10 #include "vm/thread.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 bool Scanner::IsLetter(int32_t c) { 111 bool Scanner::IsLetter(int32_t c) {
112 return (('A' <= c) && (c <= 'Z')) || (('a' <= c) && (c <= 'z')); 112 return (('A' <= c) && (c <= 'Z')) || (('a' <= c) && (c <= 'z'));
113 } 113 }
114 114
115 115
116 bool Scanner::IsDecimalDigit(int32_t c) { 116 bool Scanner::IsDecimalDigit(int32_t c) {
117 return '0' <= c && c <= '9'; 117 return '0' <= c && c <= '9';
118 } 118 }
119 119
120 120
121 bool Scanner::IsNumberStart(int32_t ch) {
122 return IsDecimalDigit(ch) || ch == '.';
123 }
124
125
121 bool Scanner::IsHexDigit(int32_t c) { 126 bool Scanner::IsHexDigit(int32_t c) {
122 return IsDecimalDigit(c) 127 return IsDecimalDigit(c)
123 || (('A' <= c) && (c <= 'F')) 128 || (('A' <= c) && (c <= 'F'))
124 || (('a' <= c) && (c <= 'f')); 129 || (('a' <= c) && (c <= 'f'));
125 } 130 }
126 131
127 132
128 bool Scanner::IsIdentStartChar(int32_t c) { 133 bool Scanner::IsIdentStartChar(int32_t c) {
129 return IsLetter(c) || (c == '_') || (c == '$'); 134 return IsLetter(c) || (c == '_') || (c == '$');
130 } 135 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 ScanLiteralStringChars(false); 591 ScanLiteralStringChars(false);
587 } 592 }
588 break; 593 break;
589 } 594 }
590 switch (c0_) { 595 switch (c0_) {
591 case '\0': 596 case '\0':
592 current_token_.kind = Token::kEOS; 597 current_token_.kind = Token::kEOS;
593 break; 598 break;
594 599
595 case '+': // + ++ += 600 case '+': // + ++ +=
596 Recognize(Token::kADD); 601 ReadChar();
602 current_token_.kind =
603 IsNumberStart(c0_) ? Token::kTIGHTADD : Token::kADD;
597 if (c0_ == '+') { 604 if (c0_ == '+') {
598 Recognize(Token::kINCR); 605 Recognize(Token::kINCR);
599 } else if (c0_ == '=') { 606 } else if (c0_ == '=') {
600 Recognize(Token::kASSIGN_ADD); 607 Recognize(Token::kASSIGN_ADD);
601 } 608 }
602 break; 609 break;
603 610
604 case '-': // - -- -= 611 case '-': // - -- -=
605 Recognize(Token::kSUB); 612 Recognize(Token::kSUB);
606 if (c0_ == '-') { 613 if (c0_ == '-') {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); 890 "%c%"PRIxPTR, kPrivateKeySeparator, key_value);
884 const String& result = String::Handle(String::New(private_key)); 891 const String& result = String::Handle(String::New(private_key));
885 return result.raw(); 892 return result.raw();
886 } 893 }
887 894
888 895
889 void Scanner::InitOnce() { 896 void Scanner::InitOnce() {
890 } 897 }
891 898
892 } // namespace dart 899 } // namespace dart
OLDNEW
« runtime/vm/parser.cc ('K') | « runtime/vm/scanner.h ('k') | runtime/vm/scanner_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698