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

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

Issue 10310040: Sort the output (for now just the classes and instance members). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 8 years, 7 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 final int EOF_TOKEN = 0; 5 final int EOF_TOKEN = 0;
6 6
7 final int KEYWORD_TOKEN = $k; 7 final int KEYWORD_TOKEN = $k;
8 final int IDENTIFIER_TOKEN = $a; 8 final int IDENTIFIER_TOKEN = $a;
9 final int DOUBLE_TOKEN = $d; 9 final int DOUBLE_TOKEN = $d;
10 final int INT_TOKEN = $i; 10 final int INT_TOKEN = $i;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 : this.fromSource(info, new SourceString(value), charOffset); 119 : this.fromSource(info, new SourceString(value), charOffset);
120 120
121 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset) 121 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset)
122 : super(info, charOffset); 122 : super(info, charOffset);
123 123
124 String toString() => "StringToken(${value.slowToString()})"; 124 String toString() => "StringToken(${value.slowToString()})";
125 125
126 String slowToString() => value.slowToString(); 126 String slowToString() => value.slowToString();
127 } 127 }
128 128
129 interface SourceString extends Hashable, Iterable<int> default StringWrapper { 129 interface SourceString extends Comparable, Hashable, Iterable<int>
130 default StringWrapper {
130 const SourceString(String string); 131 const SourceString(String string);
131 132
132 void printOn(StringBuffer sb); 133 void printOn(StringBuffer sb);
133 134
134 /** Gives a [SourceString] that is not including the [initial] first and 135 /** Gives a [SourceString] that is not including the [initial] first and
135 * [terminal] last characters. This is only intended to be used to remove 136 * [terminal] last characters. This is only intended to be used to remove
136 * quotes from string literals (including an initial '@' for raw strings). 137 * quotes from string literals (including an initial '@' for raw strings).
137 */ 138 */
138 SourceString copyWithoutQuotes(int initial, int terminal); 139 SourceString copyWithoutQuotes(int initial, int terminal);
139 140
140 String get stringValue(); 141 String get stringValue();
141 142
142 String slowToString(); 143 String slowToString();
143 144
144 bool isEmpty(); 145 bool isEmpty();
145 146
146 bool isPrivate(); 147 bool isPrivate();
147 } 148 }
148 149
150 int sourceStringCompare(SourceString string1, SourceString string2) {
151 Iterator<int> iterator1 = string1.iterator();
152 Iterator<int> iterator2 = string2.iterator();
153 while (iterator1.hasNext()) {
154 if (!iterator2.hasNext()) return 1;
155 int char1 = iterator1.next();
156 int char2 = iterator2.next();
157 int comparison = char1.compareTo(char2);
158 if (comparison != 0) return comparison;
159 }
160 if (iterator2.hasNext()) return -1;
161 return 0;
162 }
163
149 class StringWrapper implements SourceString { 164 class StringWrapper implements SourceString {
150 final String stringValue; 165 final String stringValue;
151 166
152 const StringWrapper(String this.stringValue); 167 const StringWrapper(String this.stringValue);
153 168
154 int hashCode() => stringValue.hashCode(); 169 int hashCode() => stringValue.hashCode();
155 170
171 int compareTo(SourceString other) {
172 if (other is StringWrapper) {
173 StringWrapper otherWrapper = other;
174 return stringValue.compareTo(otherWrapper.stringValue);
175 }
176 return sourceStringCompare(this, other);
177 }
178
156 bool operator ==(other) { 179 bool operator ==(other) {
157 return other is SourceString && toString() == other.slowToString(); 180 return other is SourceString && toString() == other.slowToString();
158 } 181 }
159 182
160 Iterator<int> iterator() => new StringCodeIterator(stringValue); 183 Iterator<int> iterator() => new StringCodeIterator(stringValue);
161 184
162 void printOn(StringBuffer sb) { 185 void printOn(StringBuffer sb) {
163 sb.add(stringValue); 186 sb.add(stringValue);
164 } 187 }
165 188
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 final PrecedenceInfo STRING_INTERPOLATION_INFO = 458 final PrecedenceInfo STRING_INTERPOLATION_INFO =
436 const PrecedenceInfo(const SourceString('\${'), 0, 459 const PrecedenceInfo(const SourceString('\${'), 0,
437 STRING_INTERPOLATION_TOKEN); 460 STRING_INTERPOLATION_TOKEN);
438 461
439 final PrecedenceInfo HEXADECIMAL_INFO = 462 final PrecedenceInfo HEXADECIMAL_INFO =
440 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); 463 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN);
441 464
442 // For reporting lexical errors. 465 // For reporting lexical errors.
443 final PrecedenceInfo ERROR_INFO = 466 final PrecedenceInfo ERROR_INFO =
444 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); 467 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698