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

Side by Side Diff: frog/leg/scanner/string_scanner.dart

Issue 9204006: Make SourceString Iterable<int>. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « frog/leg/scanner/byte_strings.dart ('k') | frog/leg/scanner/token.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * Scanner that reads from a String and creates tokens that points to 6 * Scanner that reads from a String and creates tokens that points to
7 * substrings. 7 * substrings.
8 */ 8 */
9 class StringScanner extends ArrayBasedScanner<SourceString> { 9 class StringScanner extends ArrayBasedScanner<SourceString> {
10 final String string; 10 final String string;
(...skipping 29 matching lines...) Expand all
40 40
41 const SubstringWrapper(String this.internalString, 41 const SubstringWrapper(String this.internalString,
42 int this.begin, int this.end); 42 int this.begin, int this.end);
43 43
44 int hashCode() => toString().hashCode(); 44 int hashCode() => toString().hashCode();
45 45
46 bool operator ==(other) { 46 bool operator ==(other) {
47 return other is SourceString && toString() == other.toString(); 47 return other is SourceString && toString() == other.toString();
48 } 48 }
49 49
50 Iterator<int> iterator() =>
51 new StringCodeIterator.substring(stringValue, begin, end);
52
50 int get length() => end - begin; 53 int get length() => end - begin;
51 54
52 void printOn(StringBuffer sb) { 55 void printOn(StringBuffer sb) {
53 sb.add(this); 56 sb.add(this);
54 } 57 }
55 58
56 String toString() => internalString.substring(begin, end); 59 String toString() => internalString.substring(begin, end);
57 60
58 String get stringValue() => toString(); 61 String get stringValue() => toString();
59 } 62 }
OLDNEW
« no previous file with comments | « frog/leg/scanner/byte_strings.dart ('k') | frog/leg/scanner/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698