| 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/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 | 406 |
| 407 | 407 |
| 408 void Scanner::SkipLine() { | 408 void Scanner::SkipLine() { |
| 409 while (c0_ != '\n' && c0_ != '\0') { | 409 while (c0_ != '\n' && c0_ != '\0') { |
| 410 ReadChar(); | 410 ReadChar(); |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 | 413 |
| 414 | 414 |
| 415 void Scanner::ScanLibraryTag() { | 415 void Scanner::ScanScriptTag() { |
| 416 ReadChar(); | 416 ReadChar(); |
| 417 if (c0_ == '!') { | 417 if (c0_ == '!') { |
| 418 Recognize(Token::kSCRIPTTAG); | 418 Recognize(Token::kSCRIPTTAG); |
| 419 // The script tag extends to the end of the line. Just treat this | 419 // The script tag extends to the end of the line. Just treat this |
| 420 // similar to a line comment. | 420 // similar to a line comment. |
| 421 SkipLine(); | 421 SkipLine(); |
| 422 return; | 422 return; |
| 423 } | 423 } else { |
| 424 if (!IsLetter(c0_)) { | 424 ErrorMsg("unexpected character: '#'"); |
| 425 ErrorMsg("Unrecognized library tag"); | |
| 426 SkipLine(); | 425 SkipLine(); |
| 427 return; | 426 return; |
| 428 } | 427 } |
| 429 const String& ident = String::Handle(ConsumeIdentChars(false)); | |
| 430 if (ident.Equals(Symbols::Library())) { | |
| 431 current_token_.kind = Token::kLEGACY_LIBRARY; | |
| 432 return; | |
| 433 } | |
| 434 if (ident.Equals(Symbols::Import())) { | |
| 435 current_token_.kind = Token::kLEGACY_IMPORT; | |
| 436 return; | |
| 437 } | |
| 438 if (ident.Equals(Symbols::Source())) { | |
| 439 current_token_.kind = Token::kLEGACY_SOURCE; | |
| 440 return; | |
| 441 } | |
| 442 ErrorMsg("Unrecognized library token"); | |
| 443 SkipLine(); | |
| 444 } | 428 } |
| 445 | 429 |
| 446 | 430 |
| 447 void Scanner::ScanLiteralString(bool is_raw) { | 431 void Scanner::ScanLiteralString(bool is_raw) { |
| 448 ASSERT(!IsScanningString()); | 432 ASSERT(!IsScanningString()); |
| 449 ASSERT(c0_ == '"' || c0_ == '\''); | 433 ASSERT(c0_ == '"' || c0_ == '\''); |
| 450 | 434 |
| 451 // Entering string scanning mode. | 435 // Entering string scanning mode. |
| 452 BeginStringLiteral(c0_); | 436 BeginStringLiteral(c0_); |
| 453 string_is_multiline_ = (LookaheadChar(1) == c0_) && | 437 string_is_multiline_ = (LookaheadChar(1) == c0_) && |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 ScanIdent(); | 847 ScanIdent(); |
| 864 } | 848 } |
| 865 break; | 849 break; |
| 866 | 850 |
| 867 case '"': | 851 case '"': |
| 868 case '\'': | 852 case '\'': |
| 869 ScanLiteralString(false); | 853 ScanLiteralString(false); |
| 870 break; | 854 break; |
| 871 | 855 |
| 872 case '#': | 856 case '#': |
| 873 ScanLibraryTag(); | 857 ScanScriptTag(); |
| 874 break; | 858 break; |
| 875 | 859 |
| 876 default: | 860 default: |
| 877 if (IsIdentStartChar(c0_)) { | 861 if (IsIdentStartChar(c0_)) { |
| 878 ScanIdent(); | 862 ScanIdent(); |
| 879 } else if (IsDecimalDigit(c0_)) { | 863 } else if (IsDecimalDigit(c0_)) { |
| 880 ScanNumber(false); | 864 ScanNumber(false); |
| 881 } else { | 865 } else { |
| 882 char msg[128]; | 866 char msg[128]; |
| 883 char utf8_char[5]; | 867 char utf8_char[5]; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 "%c%#"Px"", kPrivateKeySeparator, key_value); | 967 "%c%#"Px"", kPrivateKeySeparator, key_value); |
| 984 const String& result = String::Handle(String::New(private_key, Heap::kOld)); | 968 const String& result = String::Handle(String::New(private_key, Heap::kOld)); |
| 985 return result.raw(); | 969 return result.raw(); |
| 986 } | 970 } |
| 987 | 971 |
| 988 | 972 |
| 989 void Scanner::InitOnce() { | 973 void Scanner::InitOnce() { |
| 990 } | 974 } |
| 991 | 975 |
| 992 } // namespace dart | 976 } // namespace dart |
| OLD | NEW |