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" |
11 #include "vm/token.h" | 11 #include "vm/token.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); | 15 DEFINE_FLAG(bool, print_tokens, false, "Print scanned tokens."); |
16 DECLARE_FLAG(bool, expose_core_impl); | |
17 | 16 |
18 void Scanner::InitKeywordTable() { | 17 void Scanner::InitKeywordTable() { |
19 for (int i = 0; i < Token::numKeywords; i++) { | 18 for (int i = 0; i < Token::numKeywords; i++) { |
20 Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i); | 19 Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i); |
21 keywords_[i].kind = token; | 20 keywords_[i].kind = token; |
22 keywords_[i].keyword_chars = Token::Str(token); | 21 keywords_[i].keyword_chars = Token::Str(token); |
23 keywords_[i].keyword_len = strlen(Token::Str(token)); | 22 keywords_[i].keyword_len = strlen(Token::Str(token)); |
24 keywords_[i].keyword_symbol = NULL; | 23 keywords_[i].keyword_symbol = NULL; |
25 } | 24 } |
26 } | 25 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return; | 244 return; |
246 } | 245 } |
247 } | 246 } |
248 i++; | 247 i++; |
249 } | 248 } |
250 | 249 |
251 // We did not read a keyword. | 250 // We did not read a keyword. |
252 current_token_.kind = Token::kIDENT; | 251 current_token_.kind = Token::kIDENT; |
253 String& literal = | 252 String& literal = |
254 String::ZoneHandle(String::NewSymbol(source_, ident_pos, ident_length)); | 253 String::ZoneHandle(String::NewSymbol(source_, ident_pos, ident_length)); |
255 if ((ident_char0 == kPrivateIdentifierStart) && !FLAG_expose_core_impl) { | 254 if (ident_char0 == kPrivateIdentifierStart) { |
256 // Private identifiers are mangled on a per script basis. | 255 // Private identifiers are mangled on a per script basis. |
257 literal = String::Concat(literal, private_key_); | 256 literal = String::Concat(literal, private_key_); |
258 literal = String::NewSymbol(literal); | 257 literal = String::NewSymbol(literal); |
259 } | 258 } |
260 current_token_.literal = &literal; | 259 current_token_.literal = &literal; |
261 } | 260 } |
262 | 261 |
263 | 262 |
264 // Parse integer or double number literal of format: | 263 // Parse integer or double number literal of format: |
265 // NUMBER = INTEGER | DOUBLE | 264 // NUMBER = INTEGER | DOUBLE |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); | 850 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); |
852 const String& result = String::Handle(String::New(private_key)); | 851 const String& result = String::Handle(String::New(private_key)); |
853 return result.raw(); | 852 return result.raw(); |
854 } | 853 } |
855 | 854 |
856 | 855 |
857 void Scanner::InitOnce() { | 856 void Scanner::InitOnce() { |
858 } | 857 } |
859 | 858 |
860 } // namespace dart | 859 } // namespace dart |
OLD | NEW |