Chromium Code Reviews| 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 const int EOF_TOKEN = 0; | 5 const int EOF_TOKEN = 0; |
| 6 | 6 |
| 7 const int KEYWORD_TOKEN = $k; | 7 const int KEYWORD_TOKEN = $k; |
| 8 const int IDENTIFIER_TOKEN = $a; | 8 const int IDENTIFIER_TOKEN = $a; |
| 9 const int BAD_INPUT_TOKEN = $X; | 9 const int BAD_INPUT_TOKEN = $X; |
| 10 const int DOUBLE_TOKEN = $d; | 10 const int DOUBLE_TOKEN = $d; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 String toString() => info.value.toString(); | 132 String toString() => info.value.toString(); |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * The text parsed by this token. | 135 * The text parsed by this token. |
| 136 */ | 136 */ |
| 137 String slowToString() => toString(); | 137 String slowToString() => toString(); |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * The number of characters parsed by this token. | 140 * The number of characters parsed by this token. |
| 141 */ | 141 */ |
| 142 int get slowCharCount => slowToString().length; | 142 int get slowCharCount { |
| 143 if (info == BAD_INPUT_INFO) { | |
|
floitsch
2012/10/12 12:23:28
add comment why this is 1.
| |
| 144 return 1; | |
| 145 } else { | |
| 146 return slowToString().length; | |
| 147 } | |
| 148 } | |
| 143 } | 149 } |
| 144 | 150 |
| 145 /** | 151 /** |
| 146 * A keyword token. | 152 * A keyword token. |
| 147 */ | 153 */ |
| 148 class KeywordToken extends Token { | 154 class KeywordToken extends Token { |
| 149 final Keyword value; | 155 final Keyword value; |
| 150 String get stringValue => value.syntax; | 156 String get stringValue => value.syntax; |
| 151 | 157 |
| 152 KeywordToken(Keyword value, int charOffset) | 158 KeywordToken(Keyword value, int charOffset) |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 | 499 |
| 494 const PrecedenceInfo HEXADECIMAL_INFO = | 500 const PrecedenceInfo HEXADECIMAL_INFO = |
| 495 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); | 501 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); |
| 496 | 502 |
| 497 const PrecedenceInfo COMMENT_INFO = | 503 const PrecedenceInfo COMMENT_INFO = |
| 498 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); | 504 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); |
| 499 | 505 |
| 500 // For reporting lexical errors. | 506 // For reporting lexical errors. |
| 501 const PrecedenceInfo ERROR_INFO = | 507 const PrecedenceInfo ERROR_INFO = |
| 502 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); | 508 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); |
| OLD | NEW |