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

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

Issue 14022007: Move Iterable implementation to collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 : this.fromSource(info, new SourceString(value), charOffset); 178 : this.fromSource(info, new SourceString(value), charOffset);
179 179
180 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset) 180 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset)
181 : super(info, charOffset); 181 : super(info, charOffset);
182 182
183 String toString() => "StringToken(${value.slowToString()})"; 183 String toString() => "StringToken(${value.slowToString()})";
184 184
185 String slowToString() => value.slowToString(); 185 String slowToString() => value.slowToString();
186 } 186 }
187 187
188 abstract class SourceString extends Iterable<int> { 188 abstract class SourceString extends IterableBase<int> {
189 const factory SourceString(String string) = StringWrapper; 189 const factory SourceString(String string) = StringWrapper;
190 190
191 void printOn(StringBuffer sb); 191 void printOn(StringBuffer sb);
192 192
193 /** Gives a [SourceString] that is not including the [initial] first and 193 /** Gives a [SourceString] that is not including the [initial] first and
194 * [terminal] last characters. This is only intended to be used to remove 194 * [terminal] last characters. This is only intended to be used to remove
195 * quotes from string literals (including an initial '@' for raw strings). 195 * quotes from string literals (including an initial '@' for raw strings).
196 */ 196 */
197 SourceString copyWithoutQuotes(int initial, int terminal); 197 SourceString copyWithoutQuotes(int initial, int terminal);
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 extends Iterable<int> implements SourceString { 208 class StringWrapper extends IterableBase<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
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 521
522 const PrecedenceInfo HEXADECIMAL_INFO = 522 const PrecedenceInfo HEXADECIMAL_INFO =
523 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); 523 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN);
524 524
525 const PrecedenceInfo COMMENT_INFO = 525 const PrecedenceInfo COMMENT_INFO =
526 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); 526 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN);
527 527
528 // For reporting lexical errors. 528 // For reporting lexical errors.
529 const PrecedenceInfo ERROR_INFO = 529 const PrecedenceInfo ERROR_INFO =
530 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); 530 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698