| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 return true; | 166 return true; |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 void Scanner::ReadChar() { | 170 void Scanner::ReadChar() { |
| 171 if (lookahead_pos_ < source_length_) { | 171 if (lookahead_pos_ < source_length_) { |
| 172 if (c0_ == '\n') { | 172 if (c0_ == '\n') { |
| 173 newline_seen_ = true; | 173 newline_seen_ = true; |
| 174 c0_pos_.line++; | 174 c0_pos_.line++; |
| 175 c0_pos_.column = 0; | 175 c0_pos_.column = 0; |
| 176 if (source_.CharAt(lookahead_pos_) == '\r') { |
| 177 // Replace a sequence of '\r' '\n' with a single '\n'. |
| 178 if (LookaheadChar(1) == '\n') { |
| 179 lookahead_pos_++; |
| 180 } |
| 181 } |
| 176 } | 182 } |
| 177 lookahead_pos_++; | 183 lookahead_pos_++; |
| 178 c0_pos_.column++; | 184 c0_pos_.column++; |
| 179 c0_ = LookaheadChar(0); | 185 c0_ = LookaheadChar(0); |
| 180 // Replace '\r' with '\n' and a sequence of | 186 // Replace '\r' with '\n'. |
| 181 // '\r' '\n' with a single '\n'. | |
| 182 if (c0_ == '\r') { | 187 if (c0_ == '\r') { |
| 183 c0_ = '\n'; | 188 c0_ = '\n'; |
| 184 if (LookaheadChar(1) == '\n') { | |
| 185 lookahead_pos_++; | |
| 186 } | |
| 187 } | 189 } |
| 188 } | 190 } |
| 189 } | 191 } |
| 190 | 192 |
| 191 | 193 |
| 192 // Look ahead 'how_many' characters. Returns the character, or '\0' if | 194 // Look ahead 'how_many' characters. Returns the character, or '\0' if |
| 193 // the lookahead position is beyond the end of the string. Does not | 195 // the lookahead position is beyond the end of the string. Does not |
| 194 // normalize line end characters into '\n'. | 196 // normalize line end characters into '\n'. |
| 195 int32_t Scanner::LookaheadChar(int how_many) { | 197 int32_t Scanner::LookaheadChar(int how_many) { |
| 196 ASSERT(how_many >= 0); | 198 ASSERT(how_many >= 0); |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); | 914 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); |
| 913 const String& result = String::Handle(String::New(private_key)); | 915 const String& result = String::Handle(String::New(private_key)); |
| 914 return result.raw(); | 916 return result.raw(); |
| 915 } | 917 } |
| 916 | 918 |
| 917 | 919 |
| 918 void Scanner::InitOnce() { | 920 void Scanner::InitOnce() { |
| 919 } | 921 } |
| 920 | 922 |
| 921 } // namespace dart | 923 } // namespace dart |
| OLD | NEW |