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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/scanner/token.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
OLDNEW
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 part of scanner; 5 part of scanner;
6 6
7 const int EOF_TOKEN = 0; 7 const int EOF_TOKEN = 0;
8 8
9 const int KEYWORD_TOKEN = $k; 9 const int KEYWORD_TOKEN = $k;
10 const int IDENTIFIER_TOKEN = $a; 10 const int IDENTIFIER_TOKEN = $a;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 String get stringValue; 199 String get stringValue;
200 200
201 String slowToString(); 201 String slowToString();
202 202
203 bool get isEmpty; 203 bool get isEmpty;
204 204
205 bool isPrivate(); 205 bool isPrivate();
206 } 206 }
207 207
208 class StringWrapper implements SourceString { 208 class StringWrapper extends Iterable<int> implements SourceString {
209 final String stringValue; 209 final String stringValue;
210 210
211 const StringWrapper(String this.stringValue); 211 const StringWrapper(String this.stringValue);
212 212
213 int get hashCode => stringValue.hashCode; 213 int get hashCode => stringValue.hashCode;
214 214
215 bool operator ==(other) { 215 bool operator ==(other) {
216 return other is SourceString && toString() == other.slowToString(); 216 return other is SourceString && toString() == other.slowToString();
217 } 217 }
218 218
219 Iterator<int> iterator() => new StringCodeIterator(stringValue); 219 Iterator<int> get iterator => new StringCodeIterator(stringValue);
220 220
221 void printOn(StringBuffer sb) { 221 void printOn(StringBuffer sb) {
222 sb.add(stringValue); 222 sb.add(stringValue);
223 } 223 }
224 224
225 String toString() => stringValue; 225 String toString() => stringValue;
226 226
227 String slowToString() => stringValue; 227 String slowToString() => stringValue;
228 228
229 SourceString copyWithoutQuotes(int initial, int terminal) { 229 SourceString copyWithoutQuotes(int initial, int terminal) {
230 assert(0 <= initial); 230 assert(0 <= initial);
231 assert(0 <= terminal); 231 assert(0 <= terminal);
232 assert(initial + terminal <= stringValue.length); 232 assert(initial + terminal <= stringValue.length);
233 return new StringWrapper( 233 return new StringWrapper(
234 stringValue.substring(initial, stringValue.length - terminal)); 234 stringValue.substring(initial, stringValue.length - terminal));
235 } 235 }
236 236
237 bool get isEmpty => stringValue.isEmpty; 237 bool get isEmpty => stringValue.isEmpty;
238 238
239 bool isPrivate() => !isEmpty && identical(stringValue.charCodeAt(0), $_); 239 bool isPrivate() => !isEmpty && identical(stringValue.charCodeAt(0), $_);
240 } 240 }
241 241
242 class StringCodeIterator implements Iterator<int> { 242 class StringCodeIterator implements Iterator<int> {
243 final String string; 243 final String string;
244 int index; 244 int index;
245 final int end; 245 final int end;
246 int _current;
246 247
247 StringCodeIterator(String string) : 248 StringCodeIterator(String string) :
248 this.string = string, index = 0, end = string.length; 249 this.string = string, index = 0, end = string.length;
249 250
250 StringCodeIterator.substring(this.string, this.index, this.end) { 251 StringCodeIterator.substring(this.string, this.index, this.end) {
251 assert(0 <= index); 252 assert(0 <= index);
252 assert(index <= end); 253 assert(index <= end);
253 assert(end <= string.length); 254 assert(end <= string.length);
254 } 255 }
255 256
256 bool get hasNext => index < end; 257 int get current => _current;
257 int next() => string.charCodeAt(index++); 258
259 bool moveNext() {
260 _current = null;
261 if (index >= end) return false;
262 _current = string.charCodeAt(index++);
263 return true;
264 }
258 } 265 }
259 266
260 class BeginGroupToken extends StringToken { 267 class BeginGroupToken extends StringToken {
261 Token endGroup; 268 Token endGroup;
262 BeginGroupToken(PrecedenceInfo info, String value, int charOffset) 269 BeginGroupToken(PrecedenceInfo info, String value, int charOffset)
263 : super(info, value, charOffset); 270 : super(info, value, charOffset);
264 } 271 }
265 272
266 bool isUserDefinableOperator(String value) { 273 bool isUserDefinableOperator(String value) {
267 return 274 return
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 510
504 const PrecedenceInfo HEXADECIMAL_INFO = 511 const PrecedenceInfo HEXADECIMAL_INFO =
505 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); 512 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN);
506 513
507 const PrecedenceInfo COMMENT_INFO = 514 const PrecedenceInfo COMMENT_INFO =
508 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); 515 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN);
509 516
510 // For reporting lexical errors. 517 // For reporting lexical errors.
511 const PrecedenceInfo ERROR_INFO = 518 const PrecedenceInfo ERROR_INFO =
512 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); 519 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698