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()) { | |
hausner
2011/11/21 19:53:58
Is there a guarantee that strings will always be o
siva
2011/11/21 21:48:04
No they are not guaranteed to be always the smalle
| |
122 return false; | |
123 } | |
124 for (int i = 0; i < str.Length(); i++) { | |
125 if (!IsIdentChar(str.CharAt(i))) { | |
hausner
2011/11/21 19:53:58
The first character in the string must be checked
siva
2011/11/21 21:48:04
Good catch.
On 2011/11/21 19:53:58, hausner wrote
| |
126 return false; | |
127 } | |
128 } | |
129 return true; | |
130 } | |
131 | |
132 | |
120 void Scanner::ReadChar() { | 133 void Scanner::ReadChar() { |
121 if (lookahead_pos_ < source_length_) { | 134 if (lookahead_pos_ < source_length_) { |
122 if (c0_ == '\n') { | 135 if (c0_ == '\n') { |
123 newline_seen_ = true; | 136 newline_seen_ = true; |
124 c0_pos_.line++; | 137 c0_pos_.line++; |
125 c0_pos_.column = 0; | 138 c0_pos_.column = 0; |
126 } | 139 } |
127 lookahead_pos_++; | 140 lookahead_pos_++; |
128 c0_pos_.column++; | 141 c0_pos_.column++; |
129 c0_ = LookaheadChar(0); | 142 c0_ = LookaheadChar(0); |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); | 848 "%c%"PRIxPTR, kPrivateKeySeparator, key_value); |
836 const String& result = String::Handle(String::New(private_key)); | 849 const String& result = String::Handle(String::New(private_key)); |
837 return result.raw(); | 850 return result.raw(); |
838 } | 851 } |
839 | 852 |
840 | 853 |
841 void Scanner::InitOnce() { | 854 void Scanner::InitOnce() { |
842 } | 855 } |
843 | 856 |
844 } // namespace dart | 857 } // namespace dart |
OLD | NEW |