| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assert.h" | 7 #include "vm/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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 int ident_length = 0; | 306 int ident_length = 0; |
| 307 int32_t ident_pos = lookahead_pos_; | 307 int32_t ident_pos = lookahead_pos_; |
| 308 while (IsIdentChar(c0_) && (allow_dollar || (c0_ != '$'))) { | 308 while (IsIdentChar(c0_) && (allow_dollar || (c0_ != '$'))) { |
| 309 ReadChar(); | 309 ReadChar(); |
| 310 ident_length++; | 310 ident_length++; |
| 311 } | 311 } |
| 312 return String::NewSymbol(source_, ident_pos, ident_length); | 312 return String::NewSymbol(source_, ident_pos, ident_length); |
| 313 } | 313 } |
| 314 | 314 |
| 315 | 315 |
| 316 void Scanner::SkipLine() { |
| 317 while (c0_ != '\n' && c0_ != '\0') { |
| 318 ReadChar(); |
| 319 } |
| 320 } |
| 321 |
| 322 |
| 316 void Scanner::ScanLibraryTag() { | 323 void Scanner::ScanLibraryTag() { |
| 317 ReadChar(); | 324 ReadChar(); |
| 318 if (c0_ == '!') { | 325 if (c0_ == '!') { |
| 326 Recognize(Token::kSCRIPTTAG); |
| 319 // The script tag extends to the end of the line. Just treat this | 327 // The script tag extends to the end of the line. Just treat this |
| 320 // similar to a line comment. | 328 // similar to a line comment. |
| 321 while (c0_ != '\n' && c0_ != '\0') { | 329 SkipLine(); |
| 322 ReadChar(); | 330 return; |
| 323 } | 331 } |
| 324 Recognize(Token::kSCRIPTTAG); | 332 if (!IsIdentStartChar(c0_)) { |
| 333 ErrorMsg("Unrecognized library tag"); |
| 334 SkipLine(); |
| 325 return; | 335 return; |
| 326 } | 336 } |
| 327 const String& kLibrary = String::Handle(String::NewSymbol("library")); | 337 const String& kLibrary = String::Handle(String::NewSymbol("library")); |
| 328 const String& kImport = String::Handle(String::NewSymbol("import")); | 338 const String& kImport = String::Handle(String::NewSymbol("import")); |
| 329 const String& kSource = String::Handle(String::NewSymbol("source")); | 339 const String& kSource = String::Handle(String::NewSymbol("source")); |
| 330 const String& ident = String::Handle(ConsumeIdentChars(false)); | 340 const String& ident = String::Handle(ConsumeIdentChars(false)); |
| 331 if (ident.Equals(kLibrary)) { | 341 if (ident.Equals(kLibrary)) { |
| 332 current_token_.kind = Token::kLIBRARY; | 342 current_token_.kind = Token::kLIBRARY; |
| 333 return; | 343 return; |
| 334 } | 344 } |
| 335 if (ident.Equals(kImport)) { | 345 if (ident.Equals(kImport)) { |
| 336 current_token_.kind = Token::kIMPORT; | 346 current_token_.kind = Token::kIMPORT; |
| 337 return; | 347 return; |
| 338 } | 348 } |
| 339 if (ident.Equals(kSource)) { | 349 if (ident.Equals(kSource)) { |
| 340 current_token_.kind = Token::kSOURCE; | 350 current_token_.kind = Token::kSOURCE; |
| 341 return; | 351 return; |
| 342 } | 352 } |
| 343 ErrorMsg("Unrecognized library token"); | 353 ErrorMsg("Unrecognized library token"); |
| 354 SkipLine(); |
| 344 } | 355 } |
| 345 | 356 |
| 346 | 357 |
| 347 void Scanner::ScanLiteralString(bool is_raw) { | 358 void Scanner::ScanLiteralString(bool is_raw) { |
| 348 ASSERT(!IsScanningString()); | 359 ASSERT(!IsScanningString()); |
| 349 ASSERT(c0_ == '"' || c0_ == '\''); | 360 ASSERT(c0_ == '"' || c0_ == '\''); |
| 350 | 361 |
| 351 // Entering string scanning mode. | 362 // Entering string scanning mode. |
| 352 BeginStringLiteral(c0_); | 363 BeginStringLiteral(c0_); |
| 353 string_is_multiline_ = (LookaheadChar(1) == c0_) && | 364 string_is_multiline_ = (LookaheadChar(1) == c0_) && |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); | 835 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); |
| 825 const String& result = String::Handle(String::New(private_key)); | 836 const String& result = String::Handle(String::New(private_key)); |
| 826 return result.raw(); | 837 return result.raw(); |
| 827 } | 838 } |
| 828 | 839 |
| 829 | 840 |
| 830 void Scanner::InitOnce() { | 841 void Scanner::InitOnce() { |
| 831 } | 842 } |
| 832 | 843 |
| 833 } // namespace dart | 844 } // namespace dart |
| OLD | NEW |