| 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" |
| 11 #include "vm/symbols.h" | 11 #include "vm/symbols.h" |
| 12 #include "vm/thread.h" | 12 #include "vm/thread.h" |
| 13 #include "vm/token.h" | 13 #include "vm/token.h" |
| 14 #include "vm/unicode.h" |
| 14 | 15 |
| 15 namespace dart { | 16 namespace dart { |
| 16 | 17 |
| 17 DEFINE_FLAG(bool, disable_privacy, false, "Disable library privacy."); | 18 DEFINE_FLAG(bool, disable_privacy, false, "Disable library privacy."); |
| 18 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); | 19 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); |
| 19 | 20 |
| 20 void Scanner::InitKeywordTable() { | 21 void Scanner::InitKeywordTable() { |
| 21 ObjectStore* object_store = Isolate::Current()->object_store(); | 22 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 22 keyword_symbol_table_ = object_store->keyword_symbols(); | 23 keyword_symbol_table_ = object_store->keyword_symbols(); |
| 23 if (keyword_symbol_table_.IsNull()) { | 24 if (keyword_symbol_table_.IsNull()) { |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 ScanLibraryTag(); | 876 ScanLibraryTag(); |
| 876 break; | 877 break; |
| 877 | 878 |
| 878 default: | 879 default: |
| 879 if (IsIdentStartChar(c0_)) { | 880 if (IsIdentStartChar(c0_)) { |
| 880 ScanIdent(); | 881 ScanIdent(); |
| 881 } else if (IsDecimalDigit(c0_)) { | 882 } else if (IsDecimalDigit(c0_)) { |
| 882 ScanNumber(false); | 883 ScanNumber(false); |
| 883 } else { | 884 } else { |
| 884 char msg[128]; | 885 char msg[128]; |
| 886 char utf8_char[5]; |
| 887 int len = Utf8::Encode(c0_, utf8_char); |
| 888 utf8_char[len] = '\0'; |
| 885 OS::SNPrint(msg, sizeof(msg), | 889 OS::SNPrint(msg, sizeof(msg), |
| 886 "unexpected character: %c (%02x)\n", c0_, c0_); | 890 "unexpected character: '%s' (U+%04X)\n", utf8_char, c0_); |
| 887 ErrorMsg(msg); | 891 ErrorMsg(msg); |
| 888 ReadChar(); | 892 ReadChar(); |
| 889 } | 893 } |
| 890 } | 894 } |
| 891 } while (current_token_.kind == Token::kWHITESP); | 895 } while (current_token_.kind == Token::kWHITESP); |
| 892 current_token_.length = lookahead_pos_ - token_start_; | 896 current_token_.length = lookahead_pos_ - token_start_; |
| 893 } | 897 } |
| 894 | 898 |
| 895 | 899 |
| 896 void Scanner::ScanAll(GrowableTokenStream* token_stream) { | 900 void Scanner::ScanAll(GrowableTokenStream* token_stream) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 "%c%#"Px"", kPrivateKeySeparator, key_value); | 986 "%c%#"Px"", kPrivateKeySeparator, key_value); |
| 983 const String& result = String::Handle(String::New(private_key, Heap::kOld)); | 987 const String& result = String::Handle(String::New(private_key, Heap::kOld)); |
| 984 return result.raw(); | 988 return result.raw(); |
| 985 } | 989 } |
| 986 | 990 |
| 987 | 991 |
| 988 void Scanner::InitOnce() { | 992 void Scanner::InitOnce() { |
| 989 } | 993 } |
| 990 | 994 |
| 991 } // namespace dart | 995 } // namespace dart |
| OLD | NEW |