| 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 DOUBLE_TOKEN = $d; | 9 const int DOUBLE_TOKEN = $d; |
| 10 const int INT_TOKEN = $i; | 10 const int INT_TOKEN = $i; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 /** | 117 /** |
| 118 * The kind enum of this token as determined by its [info]. | 118 * The kind enum of this token as determined by its [info]. |
| 119 */ | 119 */ |
| 120 int get kind => info.kind; | 120 int get kind => info.kind; |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * The precedence level for this token. | 123 * The precedence level for this token. |
| 124 */ | 124 */ |
| 125 int get precedence => info.precedence; | 125 int get precedence => info.precedence; |
| 126 | 126 |
| 127 bool isIdentifier() { | 127 bool isIdentifier() => kind === IDENTIFIER_TOKEN; |
| 128 if (kind === IDENTIFIER_TOKEN) return true; | |
| 129 if (kind === KEYWORD_TOKEN) return value.isPseudo; | |
| 130 return false; | |
| 131 } | |
| 132 | 128 |
| 133 /** | 129 /** |
| 134 * Returns a textual representation of this token to be used for debugging | 130 * Returns a textual representation of this token to be used for debugging |
| 135 * purposes. The resulting string might contain information about the | 131 * purposes. The resulting string might contain information about the |
| 136 * structure of the token, for example 'StringToken(foo)' for the identifier | 132 * structure of the token, for example 'StringToken(foo)' for the identifier |
| 137 * token 'foo'. Use [slowToString] for the text actually parsed by the token. | 133 * token 'foo'. Use [slowToString] for the text actually parsed by the token. |
| 138 */ | 134 */ |
| 139 String toString() => info.value.toString(); | 135 String toString() => info.value.toString(); |
| 140 | 136 |
| 141 /** | 137 /** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 152 /** | 148 /** |
| 153 * A keyword token. | 149 * A keyword token. |
| 154 */ | 150 */ |
| 155 class KeywordToken extends Token { | 151 class KeywordToken extends Token { |
| 156 final Keyword value; | 152 final Keyword value; |
| 157 String get stringValue => value.syntax; | 153 String get stringValue => value.syntax; |
| 158 | 154 |
| 159 KeywordToken(Keyword value, int charOffset) | 155 KeywordToken(Keyword value, int charOffset) |
| 160 : this.value = value, super(value.info, charOffset); | 156 : this.value = value, super(value.info, charOffset); |
| 161 | 157 |
| 158 bool isIdentifier() => value.isPseudo || value.isBuiltIn; |
| 159 |
| 162 String toString() => value.syntax; | 160 String toString() => value.syntax; |
| 163 } | 161 } |
| 164 | 162 |
| 165 /** | 163 /** |
| 166 * A String-valued token. | 164 * A String-valued token. |
| 167 */ | 165 */ |
| 168 class StringToken extends Token { | 166 class StringToken extends Token { |
| 169 final SourceString value; | 167 final SourceString value; |
| 170 String get stringValue => value.stringValue; | 168 String get stringValue => value.stringValue; |
| 171 | 169 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 498 |
| 501 const PrecedenceInfo HEXADECIMAL_INFO = | 499 const PrecedenceInfo HEXADECIMAL_INFO = |
| 502 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); | 500 const PrecedenceInfo(const SourceString('hexadecimal'), 0, HEXADECIMAL_TOKEN); |
| 503 | 501 |
| 504 const PrecedenceInfo COMMENT_INFO = | 502 const PrecedenceInfo COMMENT_INFO = |
| 505 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); | 503 const PrecedenceInfo(const SourceString('comment'), 0, COMMENT_TOKEN); |
| 506 | 504 |
| 507 // For reporting lexical errors. | 505 // For reporting lexical errors. |
| 508 const PrecedenceInfo ERROR_INFO = | 506 const PrecedenceInfo ERROR_INFO = |
| 509 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); | 507 const PrecedenceInfo(const SourceString('?'), 0, UNKNOWN_TOKEN); |
| OLD | NEW |