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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 StringCodeIterator(String string) : | 239 StringCodeIterator(String string) : |
240 this.string = string, index = 0, end = string.length; | 240 this.string = string, index = 0, end = string.length; |
241 | 241 |
242 StringCodeIterator.substring(this.string, this.index, this.end) { | 242 StringCodeIterator.substring(this.string, this.index, this.end) { |
243 assert(0 <= index); | 243 assert(0 <= index); |
244 assert(index <= end); | 244 assert(index <= end); |
245 assert(end <= string.length); | 245 assert(end <= string.length); |
246 } | 246 } |
247 | 247 |
248 bool get hasNext => index < end; | 248 bool get hasNext => index < end; |
249 int next() => string.charCodeAt(index++); | 249 int next() { |
floitsch
2012/11/08 15:28:21
maybe add TODO to switch to charcode-iterator once
erikcorry
2012/11/15 13:28:25
Done.
| |
250 int charCode = string.charCodeAt(index++); | |
251 if (charCode >= 0x10000) index++; // Skip trail surrogate. | |
252 return charCode; | |
253 } | |
250 } | 254 } |
251 | 255 |
252 class BeginGroupToken extends StringToken { | 256 class BeginGroupToken extends StringToken { |
253 Token endGroup; | 257 Token endGroup; |
254 BeginGroupToken(PrecedenceInfo info, String value, int charOffset) | 258 BeginGroupToken(PrecedenceInfo info, String value, int charOffset) |
255 : super(info, value, charOffset); | 259 : super(info, value, charOffset); |
256 } | 260 } |
257 | 261 |
258 bool isUserDefinableOperator(String value) { | 262 bool isUserDefinableOperator(String value) { |
259 return | 263 return |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 | 499 |
496 const PrecedenceInfo HEXADECIMAL_INFO = | 500 const PrecedenceInfo HEXADECIMAL_INFO = |
497 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); | 501 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); |
498 | 502 |
499 const PrecedenceInfo COMMENT_INFO = | 503 const PrecedenceInfo COMMENT_INFO = |
500 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); | 504 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); |
501 | 505 |
502 // For reporting lexical errors. | 506 // For reporting lexical errors. |
503 const PrecedenceInfo ERROR_INFO = | 507 const PrecedenceInfo ERROR_INFO = |
504 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); | 508 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); |
OLD | NEW |