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 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 : this.fromSource(info, new SourceString(value), charOffset); | 170 : this.fromSource(info, new SourceString(value), charOffset); |
171 | 171 |
172 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset) | 172 StringToken.fromSource(PrecedenceInfo info, this.value, int charOffset) |
173 : super(info, charOffset); | 173 : super(info, charOffset); |
174 | 174 |
175 String toString() => "StringToken(${value.slowToString()})"; | 175 String toString() => "StringToken(${value.slowToString()})"; |
176 | 176 |
177 String slowToString() => value.slowToString(); | 177 String slowToString() => value.slowToString(); |
178 } | 178 } |
179 | 179 |
180 interface SourceString extends Iterable<int> default StringWrapper { | 180 abstract class SourceString extends Iterable<int> { |
181 const SourceString(String string); | 181 const factory SourceString(String string) = StringWrapper; |
182 | 182 |
183 void printOn(StringBuffer sb); | 183 void printOn(StringBuffer sb); |
184 | 184 |
185 /** Gives a [SourceString] that is not including the [initial] first and | 185 /** Gives a [SourceString] that is not including the [initial] first and |
186 * [terminal] last characters. This is only intended to be used to remove | 186 * [terminal] last characters. This is only intended to be used to remove |
187 * quotes from string literals (including an initial '@' for raw strings). | 187 * quotes from string literals (including an initial '@' for raw strings). |
188 */ | 188 */ |
189 SourceString copyWithoutQuotes(int initial, int terminal); | 189 SourceString copyWithoutQuotes(int initial, int terminal); |
190 | 190 |
191 String get stringValue; | 191 String get stringValue; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 495 |
496 const PrecedenceInfo HEXADECIMAL_INFO = | 496 const PrecedenceInfo HEXADECIMAL_INFO = |
497 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); | 497 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); |
498 | 498 |
499 const PrecedenceInfo COMMENT_INFO = | 499 const PrecedenceInfo COMMENT_INFO = |
500 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); | 500 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); |
501 | 501 |
502 // For reporting lexical errors. | 502 // For reporting lexical errors. |
503 const PrecedenceInfo ERROR_INFO = | 503 const PrecedenceInfo ERROR_INFO = |
504 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); | 504 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); |
OLD | NEW |