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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 String toString() => info.value.toString(); | 134 String toString() => info.value.toString(); |
135 | 135 |
136 /** | 136 /** |
137 * The text parsed by this token. | 137 * The text parsed by this token. |
138 */ | 138 */ |
139 String slowToString() => toString(); | 139 String slowToString() => toString(); |
140 | 140 |
141 /** | 141 /** |
142 * The number of characters parsed by this token. | 142 * The number of characters parsed by this token. |
143 */ | 143 */ |
144 int get slowCharCount => slowToString().length; | 144 int get slowCharCount { |
| 145 if (info == BAD_INPUT_INFO) { |
| 146 // This is a token that wraps around an error message. Return 1 |
| 147 // instead of the size of the length of the error message. |
| 148 return 1; |
| 149 } else { |
| 150 return slowToString().length; |
| 151 } |
| 152 } |
145 } | 153 } |
146 | 154 |
147 /** | 155 /** |
148 * A keyword token. | 156 * A keyword token. |
149 */ | 157 */ |
150 class KeywordToken extends Token { | 158 class KeywordToken extends Token { |
151 final Keyword value; | 159 final Keyword value; |
152 String get stringValue => value.syntax; | 160 String get stringValue => value.syntax; |
153 | 161 |
154 KeywordToken(Keyword value, int charOffset) | 162 KeywordToken(Keyword value, int charOffset) |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 503 |
496 const PrecedenceInfo HEXADECIMAL_INFO = | 504 const PrecedenceInfo HEXADECIMAL_INFO = |
497 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); | 505 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); |
498 | 506 |
499 const PrecedenceInfo COMMENT_INFO = | 507 const PrecedenceInfo COMMENT_INFO = |
500 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); | 508 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); |
501 | 509 |
502 // For reporting lexical errors. | 510 // For reporting lexical errors. |
503 const PrecedenceInfo ERROR_INFO = | 511 const PrecedenceInfo ERROR_INFO = |
504 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); | 512 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); |
OLD | NEW |