Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 int32_t Scanner::LookaheadChar(int how_many) { | 179 int32_t Scanner::LookaheadChar(int how_many) { |
| 180 ASSERT(how_many >= 0); | 180 ASSERT(how_many >= 0); |
| 181 int32_t lookahead_char = '\0'; | 181 int32_t lookahead_char = '\0'; |
| 182 if (lookahead_pos_ + how_many < source_length_) { | 182 if (lookahead_pos_ + how_many < source_length_) { |
| 183 lookahead_char = source_.CharAt(lookahead_pos_ + how_many); | 183 lookahead_char = source_.CharAt(lookahead_pos_ + how_many); |
| 184 } | 184 } |
| 185 return lookahead_char; | 185 return lookahead_char; |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 189 static bool IsWhiteSpace(char ch) { | |
|
hausner
2012/01/31 18:09:46
This definition of what a whitespace character is
srdjan
2012/01/31 19:26:37
Discussed the difference offline. Removed the meth
| |
| 190 return ch == '\0' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t'; | |
| 191 } | |
| 192 | |
| 193 | |
| 189 void Scanner::ConsumeWhiteSpace() { | 194 void Scanner::ConsumeWhiteSpace() { |
| 190 while (c0_ == ' ' || c0_ == '\t' || c0_ == '\n') { | 195 while (c0_ == ' ' || c0_ == '\t' || c0_ == '\n') { |
| 191 ReadChar(); | 196 ReadChar(); |
| 192 } | 197 } |
| 193 } | 198 } |
| 194 | 199 |
| 195 | 200 |
| 196 void Scanner::ConsumeLineComment() { | 201 void Scanner::ConsumeLineComment() { |
| 197 ASSERT(c0_ == '/'); | 202 ASSERT(c0_ == '/'); |
| 198 while (c0_ != '\n' && c0_ != '\0') { | 203 while (c0_ != '\n' && c0_ != '\0') { |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 IsWhiteSpace(c0_) ? Token::kADD : Token::kTIGHTADD; | |
|
hausner
2012/01/31 18:09:46
Would it not make more sense to reverse the logic
srdjan
2012/01/31 19:26:37
Changed.
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |