Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: runtime/vm/scanner.cc

Issue 9466030: Fixing bugs: 1612, 1843, 1847 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
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 16
17 void Scanner::InitKeywordTable() { 17 void Scanner::InitKeywordTable() {
18 for (int i = 0; i < Token::numKeywords; i++) { 18 for (int i = 0; i < Token::numKeywords; i++) {
19 Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i); 19 Token::Kind token = static_cast<Token::Kind>(Token::kFirstKeyword + i);
20 keywords_[i].kind = token; 20 keywords_[i].kind = token;
21 keywords_[i].keyword_chars = Token::Str(token); 21 keywords_[i].keyword_chars = Token::Str(token);
22 keywords_[i].keyword_len = strlen(Token::Str(token)); 22 keywords_[i].keyword_len = strlen(Token::Str(token));
23 keywords_[i].keyword_symbol = NULL; 23 keywords_[i].keyword_symbol = NULL;
24 } 24 }
25 } 25 }
26 26
27 27
28 void Scanner::Reset() { 28 void Scanner::Reset() {
29 lookahead_pos_ = 0; 29 lookahead_pos_ = -1;
30 token_start_ = 0; 30 token_start_ = 0;
31 c0_ = source_length_ == 0 ? '\0' : source_.CharAt(0); 31 c0_ = '\0';
32 newline_seen_ = false; 32 newline_seen_ = false;
33 while (saved_context_ != NULL) { 33 while (saved_context_ != NULL) {
34 ScanContext* ctx = saved_context_; 34 ScanContext* ctx = saved_context_;
35 saved_context_ = ctx->next; 35 saved_context_ = ctx->next;
36 delete ctx; 36 delete ctx;
37 } 37 }
38 string_delimiter_ = '\0'; 38 string_delimiter_ = '\0';
39 string_is_multiline_ = false; 39 string_is_multiline_ = false;
40 brace_level_ = 0; 40 brace_level_ = 0;
41 c0_pos_.line = 1; 41 c0_pos_.line = 1;
42 c0_pos_.column = 1; 42 c0_pos_.column = 0;
43 ReadChar();
43 } 44 }
44 45
45 46
46 Scanner::Scanner(const String& src, const String& private_key) 47 Scanner::Scanner(const String& src, const String& private_key)
47 : source_(src), 48 : source_(src),
48 source_length_(src.Length()), 49 source_length_(src.Length()),
49 saved_context_(NULL), 50 saved_context_(NULL),
50 private_key_(String::ZoneHandle(private_key.raw())) { 51 private_key_(String::ZoneHandle(private_key.raw())) {
51 Reset(); 52 Reset();
52 InitKeywordTable(); 53 InitKeywordTable();
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); 897 "%c%"PRIxPTR, kPrivateKeySeparator, key_value);
897 const String& result = String::Handle(String::New(private_key)); 898 const String& result = String::Handle(String::New(private_key));
898 return result.raw(); 899 return result.raw();
899 } 900 }
900 901
901 902
902 void Scanner::InitOnce() { 903 void Scanner::InitOnce() {
903 } 904 }
904 905
905 } // namespace dart 906 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698