| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 bool Scanner::IsIdentStartChar(int32_t c) { | 110 bool Scanner::IsIdentStartChar(int32_t c) { |
| 111 return IsLetter(c) || (c == '_') || (c == '$'); | 111 return IsLetter(c) || (c == '_') || (c == '$'); |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 bool Scanner::IsIdentChar(int32_t c) { | 115 bool Scanner::IsIdentChar(int32_t c) { |
| 116 return IsLetter(c) || IsDecimalDigit(c) || (c == '_') || (c == '$'); | 116 return IsLetter(c) || IsDecimalDigit(c) || (c == '_') || (c == '$'); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 bool Scanner::IsIdent(const String& str) { |
| 121 if (!str.IsOneByteString()) { |
| 122 return false; |
| 123 } |
| 124 if (str.Length() == 0 || !IsIdentStartChar(str.CharAt(0))) { |
| 125 return false; |
| 126 } |
| 127 for (int i = 1; i < str.Length(); i++) { |
| 128 if (!IsIdentChar(str.CharAt(i))) { |
| 129 return false; |
| 130 } |
| 131 } |
| 132 return true; |
| 133 } |
| 134 |
| 135 |
| 120 void Scanner::ReadChar() { | 136 void Scanner::ReadChar() { |
| 121 if (lookahead_pos_ < source_length_) { | 137 if (lookahead_pos_ < source_length_) { |
| 122 if (c0_ == '\n') { | 138 if (c0_ == '\n') { |
| 123 newline_seen_ = true; | 139 newline_seen_ = true; |
| 124 c0_pos_.line++; | 140 c0_pos_.line++; |
| 125 c0_pos_.column = 0; | 141 c0_pos_.column = 0; |
| 126 } | 142 } |
| 127 lookahead_pos_++; | 143 lookahead_pos_++; |
| 128 c0_pos_.column++; | 144 c0_pos_.column++; |
| 129 c0_ = LookaheadChar(0); | 145 c0_ = LookaheadChar(0); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); | 851 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); |
| 836 const String& result = String::Handle(String::New(private_key)); | 852 const String& result = String::Handle(String::New(private_key)); |
| 837 return result.raw(); | 853 return result.raw(); |
| 838 } | 854 } |
| 839 | 855 |
| 840 | 856 |
| 841 void Scanner::InitOnce() { | 857 void Scanner::InitOnce() { |
| 842 } | 858 } |
| 843 | 859 |
| 844 } // namespace dart | 860 } // namespace dart |
| OLD | NEW |