| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.scanner; | 8 library engine.scanner; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 strings[i] = values[i].syntax; | 90 strings[i] = values[i].syntax; |
| 91 } | 91 } |
| 92 strings.sort(); | 92 strings.sort(); |
| 93 return _computeKeywordStateTable(0, strings, 0, strings.length); | 93 return _computeKeywordStateTable(0, strings, 0, strings.length); |
| 94 } | 94 } |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * A table mapping characters to the states to which those characters will tra
nsition. (The index | 97 * A table mapping characters to the states to which those characters will tra
nsition. (The index |
| 98 * into the array is the offset from the character `'a'` to the transitioning
character.) | 98 * into the array is the offset from the character `'a'` to the transitioning
character.) |
| 99 */ | 99 */ |
| 100 final List<KeywordState> _table; | 100 List<KeywordState> _table; |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * The keyword that is recognized by this state, or `null` if this state is no
t a terminal | 103 * The keyword that is recognized by this state, or `null` if this state is no
t a terminal |
| 104 * state. | 104 * state. |
| 105 */ | 105 */ |
| 106 Keyword _keyword; | 106 Keyword _keyword; |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * Initialize a newly created state to have the given transitions and to recog
nize the keyword | 109 * Initialize a newly created state to have the given transitions and to recog
nize the keyword |
| 110 * with the given syntax. | 110 * with the given syntax. |
| 111 * | 111 * |
| 112 * @param table a table mapping characters to the states to which those charac
ters will transition | 112 * @param table a table mapping characters to the states to which those charac
ters will transition |
| 113 * @param syntax the syntax of the keyword that is recognized by the state | 113 * @param syntax the syntax of the keyword that is recognized by the state |
| 114 */ | 114 */ |
| 115 KeywordState(this._table, String syntax) { | 115 KeywordState(List<KeywordState> table, String syntax) { |
| 116 this._table = table; |
| 116 this._keyword = (syntax == null) ? null : Keyword.keywords[syntax]; | 117 this._keyword = (syntax == null) ? null : Keyword.keywords[syntax]; |
| 117 } | 118 } |
| 118 | 119 |
| 119 /** | 120 /** |
| 120 * Return the keyword that was recognized by this state, or `null` if this sta
te does not | 121 * Return the keyword that was recognized by this state, or `null` if this sta
te does not |
| 121 * recognized a keyword. | 122 * recognized a keyword. |
| 122 * | 123 * |
| 123 * @return the keyword that was matched by reaching this state | 124 * @return the keyword that was matched by reaching this state |
| 124 */ | 125 */ |
| 125 Keyword keyword() => _keyword; | 126 Keyword keyword() => _keyword; |
| 126 | 127 |
| 127 /** | 128 /** |
| 128 * Return the state that follows this state on a transition of the given chara
cter, or | 129 * Return the state that follows this state on a transition of the given chara
cter, or |
| 129 * `null` if there is no valid state reachable from this state with such a tra
nsition. | 130 * `null` if there is no valid state reachable from this state with such a tra
nsition. |
| 130 * | 131 * |
| 131 * @param c the character used to transition from this state to another state | 132 * @param c the character used to transition from this state to another state |
| 132 * @return the state that follows this state on a transition of the given char
acter | 133 * @return the state that follows this state on a transition of the given char
acter |
| 133 */ | 134 */ |
| 134 KeywordState next(int c) => _table[c - 0x61]; | 135 KeywordState next(int c) => _table[c - 0x61]; |
| 135 } | 136 } |
| 136 | 137 |
| 137 /** | 138 /** |
| 138 * The enumeration `ScannerErrorCode` defines the error codes used for errors de
tected by the | 139 * The enumeration `ScannerErrorCode` defines the error codes used for errors de
tected by the |
| 139 * scanner. | 140 * scanner. |
| 140 */ | 141 */ |
| 141 class ScannerErrorCode extends Enum<ScannerErrorCode> implements ErrorCode { | 142 class ScannerErrorCode extends Enum<ScannerErrorCode> implements ErrorCode { |
| 142 static const ScannerErrorCode ILLEGAL_CHARACTER = const ScannerErrorCode.con1(
'ILLEGAL_CHARACTER', 0, "Illegal character %x"); | 143 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode.con1('I
LLEGAL_CHARACTER', 0, "Illegal character %x"); |
| 143 | 144 |
| 144 static const ScannerErrorCode MISSING_DIGIT = const ScannerErrorCode.con1('MIS
SING_DIGIT', 1, "Decimal digit expected"); | 145 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode.con1('MISSI
NG_DIGIT', 1, "Decimal digit expected"); |
| 145 | 146 |
| 146 static const ScannerErrorCode MISSING_HEX_DIGIT = const ScannerErrorCode.con1(
'MISSING_HEX_DIGIT', 2, "Hexidecimal digit expected"); | 147 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode.con1('M
ISSING_HEX_DIGIT', 2, "Hexidecimal digit expected"); |
| 147 | 148 |
| 148 static const ScannerErrorCode MISSING_QUOTE = const ScannerErrorCode.con1('MIS
SING_QUOTE', 3, "Expected quote (' or \")"); | 149 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode.con1('MISSI
NG_QUOTE', 3, "Expected quote (' or \")"); |
| 149 | 150 |
| 150 static const ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = const ScannerE
rrorCode.con1('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line com
ment"); | 151 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr
orCode.con1('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comme
nt"); |
| 151 | 152 |
| 152 static const ScannerErrorCode UNTERMINATED_STRING_LITERAL = const ScannerError
Code.con1('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); | 153 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo
de.con1('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); |
| 153 | 154 |
| 154 static const List<ScannerErrorCode> values = const [ | 155 static final List<ScannerErrorCode> values = [ |
| 155 ILLEGAL_CHARACTER, | 156 ILLEGAL_CHARACTER, |
| 156 MISSING_DIGIT, | 157 MISSING_DIGIT, |
| 157 MISSING_HEX_DIGIT, | 158 MISSING_HEX_DIGIT, |
| 158 MISSING_QUOTE, | 159 MISSING_QUOTE, |
| 159 UNTERMINATED_MULTI_LINE_COMMENT, | 160 UNTERMINATED_MULTI_LINE_COMMENT, |
| 160 UNTERMINATED_STRING_LITERAL]; | 161 UNTERMINATED_STRING_LITERAL]; |
| 161 | 162 |
| 162 /** | 163 /** |
| 163 * The template used to create the message to be displayed for this error. | 164 * The template used to create the message to be displayed for this error. |
| 164 */ | 165 */ |
| 165 final String message; | 166 String message; |
| 166 | 167 |
| 167 /** | 168 /** |
| 168 * The template used to create the correction to be displayed for this error,
or `null` if | 169 * The template used to create the correction to be displayed for this error,
or `null` if |
| 169 * there is no correction information for this error. | 170 * there is no correction information for this error. |
| 170 */ | 171 */ |
| 171 final String correction; | 172 String correction10; |
| 172 | 173 |
| 173 /** | 174 /** |
| 174 * Initialize a newly created error code to have the given message. | 175 * Initialize a newly created error code to have the given message. |
| 175 * | 176 * |
| 176 * @param message the message template used to create the message to be displa
yed for this error | 177 * @param message the message template used to create the message to be displa
yed for this error |
| 177 */ | 178 */ |
| 178 const ScannerErrorCode.con1(String name, int ordinal, String message) : this.c
on2(name, ordinal, message, null); | 179 ScannerErrorCode.con1(String name, int ordinal, String message) : super(name,
ordinal) { |
| 180 this.message = message; |
| 181 } |
| 179 | 182 |
| 180 /** | 183 /** |
| 181 * Initialize a newly created error code to have the given message and correct
ion. | 184 * Initialize a newly created error code to have the given message and correct
ion. |
| 182 * | 185 * |
| 183 * @param message the template used to create the message to be displayed for
the error | 186 * @param message the template used to create the message to be displayed for
the error |
| 184 * @param correction the template used to create the correction to be displaye
d for the error | 187 * @param correction the template used to create the correction to be displaye
d for the error |
| 185 */ | 188 */ |
| 186 const ScannerErrorCode.con2(String name, int ordinal, this.message, this.corre
ction) : super(name, ordinal); | 189 ScannerErrorCode.con2(String name, int ordinal, String message, String correct
ion) : super(name, ordinal) { |
| 190 this.message = message; |
| 191 this.correction10 = correction; |
| 192 } |
| 193 |
| 194 @override |
| 195 String get correction => correction10; |
| 187 | 196 |
| 188 @override | 197 @override |
| 189 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; | 198 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; |
| 190 | 199 |
| 191 @override | 200 @override |
| 192 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 201 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 193 } | 202 } |
| 194 | 203 |
| 195 /** | 204 /** |
| 196 * Instances of the class `SubSequenceReader` implement a [CharacterReader] that
reads | 205 * Instances of the class `SubSequenceReader` implement a [CharacterReader] that
reads |
| 197 * characters from a character sequence, but adds a delta when reporting the cur
rent character | 206 * characters from a character sequence, but adds a delta when reporting the cur
rent character |
| 198 * offset so that the character sequence can be a subsequence from a larger sequ
ence. | 207 * offset so that the character sequence can be a subsequence from a larger sequ
ence. |
| 199 */ | 208 */ |
| 200 class SubSequenceReader extends CharSequenceReader { | 209 class SubSequenceReader extends CharSequenceReader { |
| 201 /** | 210 /** |
| 202 * The offset from the beginning of the file to the beginning of the source be
ing scanned. | 211 * The offset from the beginning of the file to the beginning of the source be
ing scanned. |
| 203 */ | 212 */ |
| 204 final int _offsetDelta; | 213 int _offsetDelta = 0; |
| 205 | 214 |
| 206 /** | 215 /** |
| 207 * Initialize a newly created reader to read the characters in the given seque
nce. | 216 * Initialize a newly created reader to read the characters in the given seque
nce. |
| 208 * | 217 * |
| 209 * @param sequence the sequence from which characters will be read | 218 * @param sequence the sequence from which characters will be read |
| 210 * @param offsetDelta the offset from the beginning of the file to the beginni
ng of the source | 219 * @param offsetDelta the offset from the beginning of the file to the beginni
ng of the source |
| 211 * being scanned | 220 * being scanned |
| 212 */ | 221 */ |
| 213 SubSequenceReader(String sequence, this._offsetDelta) : super(sequence); | 222 SubSequenceReader(String sequence, int offsetDelta) : super(sequence) { |
| 223 this._offsetDelta = offsetDelta; |
| 224 } |
| 214 | 225 |
| 215 @override | 226 @override |
| 216 int get offset => _offsetDelta + super.offset; | 227 int get offset => _offsetDelta + super.offset; |
| 217 | 228 |
| 218 @override | 229 @override |
| 219 String getString(int start, int endDelta) => super.getString(start - _offsetDe
lta, endDelta); | 230 String getString(int start, int endDelta) => super.getString(start - _offsetDe
lta, endDelta); |
| 220 | 231 |
| 221 @override | 232 @override |
| 222 void set offset(int offset) { | 233 void set offset(int offset) { |
| 223 super.offset = offset - _offsetDelta; | 234 super.offset = offset - _offsetDelta; |
| 224 } | 235 } |
| 225 } | 236 } |
| 226 | 237 |
| 227 /** | 238 /** |
| 228 * Instances of the class `TokenWithComment` represent a string token that is pr
eceded by | 239 * Instances of the class `TokenWithComment` represent a string token that is pr
eceded by |
| 229 * comments. | 240 * comments. |
| 230 */ | 241 */ |
| 231 class StringTokenWithComment extends StringToken { | 242 class StringTokenWithComment extends StringToken { |
| 232 /** | 243 /** |
| 233 * The first comment in the list of comments that precede this token. | 244 * The first comment in the list of comments that precede this token. |
| 234 */ | 245 */ |
| 235 final Token _precedingComment; | 246 Token _precedingComment; |
| 236 | 247 |
| 237 /** | 248 /** |
| 238 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 249 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 239 * comments reachable from the given comment. | 250 * comments reachable from the given comment. |
| 240 * | 251 * |
| 241 * @param type the type of the token | 252 * @param type the type of the token |
| 242 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 253 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 243 * @param precedingComment the first comment in the list of comments that prec
ede this token | 254 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 244 */ | 255 */ |
| 245 StringTokenWithComment(TokenType type, String value, int offset, this._precedi
ngComment) : super(type, value, offset); | 256 StringTokenWithComment(TokenType type, String value, int offset, Token precedi
ngComment) : super(type, value, offset) { |
| 257 this._precedingComment = precedingComment; |
| 258 } |
| 246 | 259 |
| 247 @override | 260 @override |
| 248 Token copy() => new StringTokenWithComment(type, lexeme, offset, copyComments(
_precedingComment)); | 261 Token copy() => new StringTokenWithComment(type, lexeme, offset, copyComments(
_precedingComment)); |
| 249 | 262 |
| 250 @override | 263 @override |
| 251 Token get precedingComments => _precedingComment; | 264 Token get precedingComments => _precedingComment; |
| 252 | 265 |
| 253 @override | 266 @override |
| 254 void applyDelta(int delta) { | 267 void applyDelta(int delta) { |
| 255 super.applyDelta(delta); | 268 super.applyDelta(delta); |
| 256 Token token = _precedingComment; | 269 Token token = _precedingComment; |
| 257 while (token != null) { | 270 while (token != null) { |
| 258 token.applyDelta(delta); | 271 token.applyDelta(delta); |
| 259 token = token.next; | 272 token = token.next; |
| 260 } | 273 } |
| 261 } | 274 } |
| 262 } | 275 } |
| 263 | 276 |
| 264 /** | 277 /** |
| 265 * The enumeration `Keyword` defines the keywords in the Dart programming langua
ge. | 278 * The enumeration `Keyword` defines the keywords in the Dart programming langua
ge. |
| 266 */ | 279 */ |
| 267 class Keyword extends Enum<Keyword> { | 280 class Keyword extends Enum<Keyword> { |
| 268 static const Keyword ASSERT = const Keyword.con1('ASSERT', 0, "assert"); | 281 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); |
| 269 | 282 |
| 270 static const Keyword BREAK = const Keyword.con1('BREAK', 1, "break"); | 283 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); |
| 271 | 284 |
| 272 static const Keyword CASE = const Keyword.con1('CASE', 2, "case"); | 285 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); |
| 273 | 286 |
| 274 static const Keyword CATCH = const Keyword.con1('CATCH', 3, "catch"); | 287 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); |
| 275 | 288 |
| 276 static const Keyword CLASS = const Keyword.con1('CLASS', 4, "class"); | 289 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); |
| 277 | 290 |
| 278 static const Keyword CONST = const Keyword.con1('CONST', 5, "const"); | 291 static final Keyword CONST = new Keyword.con1('CONST', 5, "const"); |
| 279 | 292 |
| 280 static const Keyword CONTINUE = const Keyword.con1('CONTINUE', 6, "continue"); | 293 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue"); |
| 281 | 294 |
| 282 static const Keyword DEFAULT = const Keyword.con1('DEFAULT', 7, "default"); | 295 static final Keyword DEFAULT = new Keyword.con1('DEFAULT', 7, "default"); |
| 283 | 296 |
| 284 static const Keyword DO = const Keyword.con1('DO', 8, "do"); | 297 static final Keyword DO = new Keyword.con1('DO', 8, "do"); |
| 285 | 298 |
| 286 static const Keyword ELSE = const Keyword.con1('ELSE', 9, "else"); | 299 static final Keyword ELSE = new Keyword.con1('ELSE', 9, "else"); |
| 287 | 300 |
| 288 static const Keyword ENUM = const Keyword.con1('ENUM', 10, "enum"); | 301 static final Keyword ENUM = new Keyword.con1('ENUM', 10, "enum"); |
| 289 | 302 |
| 290 static const Keyword EXTENDS = const Keyword.con1('EXTENDS', 11, "extends"); | 303 static final Keyword EXTENDS = new Keyword.con1('EXTENDS', 11, "extends"); |
| 291 | 304 |
| 292 static const Keyword FALSE = const Keyword.con1('FALSE', 12, "false"); | 305 static final Keyword FALSE = new Keyword.con1('FALSE', 12, "false"); |
| 293 | 306 |
| 294 static const Keyword FINAL = const Keyword.con1('FINAL', 13, "final"); | 307 static final Keyword FINAL = new Keyword.con1('FINAL', 13, "final"); |
| 295 | 308 |
| 296 static const Keyword FINALLY = const Keyword.con1('FINALLY', 14, "finally"); | 309 static final Keyword FINALLY = new Keyword.con1('FINALLY', 14, "finally"); |
| 297 | 310 |
| 298 static const Keyword FOR = const Keyword.con1('FOR', 15, "for"); | 311 static final Keyword FOR = new Keyword.con1('FOR', 15, "for"); |
| 299 | 312 |
| 300 static const Keyword IF = const Keyword.con1('IF', 16, "if"); | 313 static final Keyword IF = new Keyword.con1('IF', 16, "if"); |
| 301 | 314 |
| 302 static const Keyword IN = const Keyword.con1('IN', 17, "in"); | 315 static final Keyword IN = new Keyword.con1('IN', 17, "in"); |
| 303 | 316 |
| 304 static const Keyword IS = const Keyword.con1('IS', 18, "is"); | 317 static final Keyword IS = new Keyword.con1('IS', 18, "is"); |
| 305 | 318 |
| 306 static const Keyword NEW = const Keyword.con1('NEW', 19, "new"); | 319 static final Keyword NEW = new Keyword.con1('NEW', 19, "new"); |
| 307 | 320 |
| 308 static const Keyword NULL = const Keyword.con1('NULL', 20, "null"); | 321 static final Keyword NULL = new Keyword.con1('NULL', 20, "null"); |
| 309 | 322 |
| 310 static const Keyword RETHROW = const Keyword.con1('RETHROW', 21, "rethrow"); | 323 static final Keyword RETHROW = new Keyword.con1('RETHROW', 21, "rethrow"); |
| 311 | 324 |
| 312 static const Keyword RETURN = const Keyword.con1('RETURN', 22, "return"); | 325 static final Keyword RETURN = new Keyword.con1('RETURN', 22, "return"); |
| 313 | 326 |
| 314 static const Keyword SUPER = const Keyword.con1('SUPER', 23, "super"); | 327 static final Keyword SUPER = new Keyword.con1('SUPER', 23, "super"); |
| 315 | 328 |
| 316 static const Keyword SWITCH = const Keyword.con1('SWITCH', 24, "switch"); | 329 static final Keyword SWITCH = new Keyword.con1('SWITCH', 24, "switch"); |
| 317 | 330 |
| 318 static const Keyword THIS = const Keyword.con1('THIS', 25, "this"); | 331 static final Keyword THIS = new Keyword.con1('THIS', 25, "this"); |
| 319 | 332 |
| 320 static const Keyword THROW = const Keyword.con1('THROW', 26, "throw"); | 333 static final Keyword THROW = new Keyword.con1('THROW', 26, "throw"); |
| 321 | 334 |
| 322 static const Keyword TRUE = const Keyword.con1('TRUE', 27, "true"); | 335 static final Keyword TRUE = new Keyword.con1('TRUE', 27, "true"); |
| 323 | 336 |
| 324 static const Keyword TRY = const Keyword.con1('TRY', 28, "try"); | 337 static final Keyword TRY = new Keyword.con1('TRY', 28, "try"); |
| 325 | 338 |
| 326 static const Keyword VAR = const Keyword.con1('VAR', 29, "var"); | 339 static final Keyword VAR = new Keyword.con1('VAR', 29, "var"); |
| 327 | 340 |
| 328 static const Keyword VOID = const Keyword.con1('VOID', 30, "void"); | 341 static final Keyword VOID = new Keyword.con1('VOID', 30, "void"); |
| 329 | 342 |
| 330 static const Keyword WHILE = const Keyword.con1('WHILE', 31, "while"); | 343 static final Keyword WHILE = new Keyword.con1('WHILE', 31, "while"); |
| 331 | 344 |
| 332 static const Keyword WITH = const Keyword.con1('WITH', 32, "with"); | 345 static final Keyword WITH = new Keyword.con1('WITH', 32, "with"); |
| 333 | 346 |
| 334 static const Keyword ABSTRACT = const Keyword.con2('ABSTRACT', 33, "abstract",
true); | 347 static final Keyword ABSTRACT = new Keyword.con2('ABSTRACT', 33, "abstract", t
rue); |
| 335 | 348 |
| 336 static const Keyword AS = const Keyword.con2('AS', 34, "as", true); | 349 static final Keyword AS = new Keyword.con2('AS', 34, "as", true); |
| 337 | 350 |
| 338 static const Keyword DYNAMIC = const Keyword.con2('DYNAMIC', 35, "dynamic", tr
ue); | 351 static final Keyword DYNAMIC = new Keyword.con2('DYNAMIC', 35, "dynamic", true
); |
| 339 | 352 |
| 340 static const Keyword EXPORT = const Keyword.con2('EXPORT', 36, "export", true)
; | 353 static final Keyword EXPORT = new Keyword.con2('EXPORT', 36, "export", true); |
| 341 | 354 |
| 342 static const Keyword EXTERNAL = const Keyword.con2('EXTERNAL', 37, "external",
true); | 355 static final Keyword EXTERNAL = new Keyword.con2('EXTERNAL', 37, "external", t
rue); |
| 343 | 356 |
| 344 static const Keyword FACTORY = const Keyword.con2('FACTORY', 38, "factory", tr
ue); | 357 static final Keyword FACTORY = new Keyword.con2('FACTORY', 38, "factory", true
); |
| 345 | 358 |
| 346 static const Keyword GET = const Keyword.con2('GET', 39, "get", true); | 359 static final Keyword GET = new Keyword.con2('GET', 39, "get", true); |
| 347 | 360 |
| 348 static const Keyword IMPLEMENTS = const Keyword.con2('IMPLEMENTS', 40, "implem
ents", true); | 361 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen
ts", true); |
| 349 | 362 |
| 350 static const Keyword IMPORT = const Keyword.con2('IMPORT', 41, "import", true)
; | 363 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true); |
| 351 | 364 |
| 352 static const Keyword LIBRARY = const Keyword.con2('LIBRARY', 42, "library", tr
ue); | 365 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true
); |
| 353 | 366 |
| 354 static const Keyword OPERATOR = const Keyword.con2('OPERATOR', 43, "operator",
true); | 367 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t
rue); |
| 355 | 368 |
| 356 static const Keyword PART = const Keyword.con2('PART', 44, "part", true); | 369 static final Keyword PART = new Keyword.con2('PART', 44, "part", true); |
| 357 | 370 |
| 358 static const Keyword SET = const Keyword.con2('SET', 45, "set", true); | 371 static final Keyword SET = new Keyword.con2('SET', 45, "set", true); |
| 359 | 372 |
| 360 static const Keyword STATIC = const Keyword.con2('STATIC', 46, "static", true)
; | 373 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true); |
| 361 | 374 |
| 362 static const Keyword TYPEDEF = const Keyword.con2('TYPEDEF', 47, "typedef", tr
ue); | 375 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true
); |
| 363 | 376 |
| 364 static const List<Keyword> values = const [ | 377 static final List<Keyword> values = [ |
| 365 ASSERT, | 378 ASSERT, |
| 366 BREAK, | 379 BREAK, |
| 367 CASE, | 380 CASE, |
| 368 CATCH, | 381 CATCH, |
| 369 CLASS, | 382 CLASS, |
| 370 CONST, | 383 CONST, |
| 371 CONTINUE, | 384 CONTINUE, |
| 372 DEFAULT, | 385 DEFAULT, |
| 373 DO, | 386 DO, |
| 374 ELSE, | 387 ELSE, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 LIBRARY, | 420 LIBRARY, |
| 408 OPERATOR, | 421 OPERATOR, |
| 409 PART, | 422 PART, |
| 410 SET, | 423 SET, |
| 411 STATIC, | 424 STATIC, |
| 412 TYPEDEF]; | 425 TYPEDEF]; |
| 413 | 426 |
| 414 /** | 427 /** |
| 415 * The lexeme for the keyword. | 428 * The lexeme for the keyword. |
| 416 */ | 429 */ |
| 417 final String syntax; | 430 String _syntax; |
| 418 | 431 |
| 419 /** | 432 /** |
| 420 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords
can be used as | 433 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords
can be used as |
| 421 * identifiers. | 434 * identifiers. |
| 422 */ | 435 */ |
| 423 final bool isPseudoKeyword; | 436 bool _isPseudoKeyword = false; |
| 424 | 437 |
| 425 /** | 438 /** |
| 426 * A table mapping the lexemes of keywords to the corresponding keyword. | 439 * A table mapping the lexemes of keywords to the corresponding keyword. |
| 427 */ | 440 */ |
| 428 static Map<String, Keyword> keywords = _createKeywordMap(); | 441 static Map<String, Keyword> keywords = _createKeywordMap(); |
| 429 | 442 |
| 430 /** | 443 /** |
| 431 * Create a table mapping the lexemes of keywords to the corresponding keyword
. | 444 * Create a table mapping the lexemes of keywords to the corresponding keyword
. |
| 432 * | 445 * |
| 433 * @return the table that was created | 446 * @return the table that was created |
| 434 */ | 447 */ |
| 435 static Map<String, Keyword> _createKeywordMap() { | 448 static Map<String, Keyword> _createKeywordMap() { |
| 436 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>()
; | 449 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>()
; |
| 437 for (Keyword keyword in values) { | 450 for (Keyword keyword in values) { |
| 438 result[keyword.syntax] = keyword; | 451 result[keyword._syntax] = keyword; |
| 439 } | 452 } |
| 440 return result; | 453 return result; |
| 441 } | 454 } |
| 442 | 455 |
| 443 /** | 456 /** |
| 444 * Initialize a newly created keyword to have the given syntax. The keyword is
not a | 457 * Initialize a newly created keyword to have the given syntax. The keyword is
not a |
| 445 * pseudo-keyword. | 458 * pseudo-keyword. |
| 446 * | 459 * |
| 447 * @param syntax the lexeme for the keyword | 460 * @param syntax the lexeme for the keyword |
| 448 */ | 461 */ |
| 449 const Keyword.con1(String name, int ordinal, String syntax) : this.con2(name,
ordinal, syntax, false); | 462 Keyword.con1(String name, int ordinal, String syntax) : this.con2(name, ordina
l, syntax, false); |
| 450 | 463 |
| 451 /** | 464 /** |
| 452 * Initialize a newly created keyword to have the given syntax. The keyword is
a pseudo-keyword if | 465 * Initialize a newly created keyword to have the given syntax. The keyword is
a pseudo-keyword if |
| 453 * the given flag is `true`. | 466 * the given flag is `true`. |
| 454 * | 467 * |
| 455 * @param syntax the lexeme for the keyword | 468 * @param syntax the lexeme for the keyword |
| 456 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword | 469 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword |
| 457 */ | 470 */ |
| 458 const Keyword.con2(String name, int ordinal, this.syntax, this.isPseudoKeyword
) : super(name, ordinal); | 471 Keyword.con2(String name, int ordinal, String syntax, bool isPseudoKeyword) :
super(name, ordinal) { |
| 472 this._syntax = syntax; |
| 473 this._isPseudoKeyword = isPseudoKeyword; |
| 474 } |
| 475 |
| 476 /** |
| 477 * Return the lexeme for the keyword. |
| 478 * |
| 479 * @return the lexeme for the keyword |
| 480 */ |
| 481 String get syntax => _syntax; |
| 482 |
| 483 /** |
| 484 * Return `true` if this keyword is a pseudo-keyword. Pseudo keywords can be u
sed as |
| 485 * identifiers. |
| 486 * |
| 487 * @return `true` if this keyword is a pseudo-keyword |
| 488 */ |
| 489 bool get isPseudoKeyword => _isPseudoKeyword; |
| 459 } | 490 } |
| 460 | 491 |
| 461 /** | 492 /** |
| 462 * Instances of the class `CharSequenceReader` implement a [CharacterReader] tha
t reads | 493 * Instances of the class `CharSequenceReader` implement a [CharacterReader] tha
t reads |
| 463 * characters from a character sequence. | 494 * characters from a character sequence. |
| 464 */ | 495 */ |
| 465 class CharSequenceReader implements CharacterReader { | 496 class CharSequenceReader implements CharacterReader { |
| 466 /** | 497 /** |
| 467 * The sequence from which characters will be read. | 498 * The sequence from which characters will be read. |
| 468 */ | 499 */ |
| 469 final String _sequence; | 500 String _sequence; |
| 470 | 501 |
| 471 /** | 502 /** |
| 472 * The number of characters in the string. | 503 * The number of characters in the string. |
| 473 */ | 504 */ |
| 474 int _stringLength = 0; | 505 int _stringLength = 0; |
| 475 | 506 |
| 476 /** | 507 /** |
| 477 * The index, relative to the string, of the last character that was read. | 508 * The index, relative to the string, of the last character that was read. |
| 478 */ | 509 */ |
| 479 int _charOffset = 0; | 510 int _charOffset = 0; |
| 480 | 511 |
| 481 /** | 512 /** |
| 482 * Initialize a newly created reader to read the characters in the given seque
nce. | 513 * Initialize a newly created reader to read the characters in the given seque
nce. |
| 483 * | 514 * |
| 484 * @param sequence the sequence from which characters will be read | 515 * @param sequence the sequence from which characters will be read |
| 485 */ | 516 */ |
| 486 CharSequenceReader(this._sequence) { | 517 CharSequenceReader(String sequence) { |
| 487 this._stringLength = _sequence.length; | 518 this._sequence = sequence; |
| 519 this._stringLength = sequence.length; |
| 488 this._charOffset = -1; | 520 this._charOffset = -1; |
| 489 } | 521 } |
| 490 | 522 |
| 491 @override | 523 @override |
| 492 int advance() { | 524 int advance() { |
| 493 if (_charOffset + 1 >= _stringLength) { | 525 if (_charOffset + 1 >= _stringLength) { |
| 494 return -1; | 526 return -1; |
| 495 } | 527 } |
| 496 return _sequence.codeUnitAt(++_charOffset); | 528 return _sequence.codeUnitAt(++_charOffset); |
| 497 } | 529 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is | 791 * The lexical structure of Dart is ambiguous without knowledge of the context i
n which a token is |
| 760 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" | 792 * being scanned. For example, without context we cannot determine whether sourc
e of the form "<<" |
| 761 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner | 793 * should be scanned as a single left-shift operator or as two left angle bracke
ts. This scanner |
| 762 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible | 794 * does not have any context, so it always resolves such conflicts by scanning t
he longest possible |
| 763 * token. | 795 * token. |
| 764 */ | 796 */ |
| 765 class Scanner { | 797 class Scanner { |
| 766 /** | 798 /** |
| 767 * The source being scanned. | 799 * The source being scanned. |
| 768 */ | 800 */ |
| 769 final Source source; | 801 Source source; |
| 770 | 802 |
| 771 /** | 803 /** |
| 772 * The reader used to access the characters in the source. | 804 * The reader used to access the characters in the source. |
| 773 */ | 805 */ |
| 774 final CharacterReader _reader; | 806 CharacterReader _reader; |
| 775 | 807 |
| 776 /** | 808 /** |
| 777 * The error listener that will be informed of any errors that are found durin
g the scan. | 809 * The error listener that will be informed of any errors that are found durin
g the scan. |
| 778 */ | 810 */ |
| 779 final AnalysisErrorListener _errorListener; | 811 AnalysisErrorListener _errorListener; |
| 780 | 812 |
| 781 /** | 813 /** |
| 782 * The flag specifying if documentation comments should be parsed. | 814 * The flag specifying if documentation comments should be parsed. |
| 783 */ | 815 */ |
| 784 bool _preserveComments = true; | 816 bool _preserveComments = true; |
| 785 | 817 |
| 786 /** | 818 /** |
| 787 * The token pointing to the head of the linked list of tokens. | 819 * The token pointing to the head of the linked list of tokens. |
| 788 */ | 820 */ |
| 789 Token _tokens; | 821 Token _tokens; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 */ | 861 */ |
| 830 bool _hasUnmatchedGroups = false; | 862 bool _hasUnmatchedGroups = false; |
| 831 | 863 |
| 832 /** | 864 /** |
| 833 * Initialize a newly created scanner. | 865 * Initialize a newly created scanner. |
| 834 * | 866 * |
| 835 * @param source the source being scanned | 867 * @param source the source being scanned |
| 836 * @param reader the character reader used to read the characters in the sourc
e | 868 * @param reader the character reader used to read the characters in the sourc
e |
| 837 * @param errorListener the error listener that will be informed of any errors
that are found | 869 * @param errorListener the error listener that will be informed of any errors
that are found |
| 838 */ | 870 */ |
| 839 Scanner(this.source, this._reader, this._errorListener) { | 871 Scanner(Source source, CharacterReader reader, AnalysisErrorListener errorList
ener) { |
| 872 this.source = source; |
| 873 this._reader = reader; |
| 874 this._errorListener = errorListener; |
| 840 _tokens = new Token(TokenType.EOF, -1); | 875 _tokens = new Token(TokenType.EOF, -1); |
| 841 _tokens.setNext(_tokens); | 876 _tokens.setNext(_tokens); |
| 842 _tail = _tokens; | 877 _tail = _tokens; |
| 843 _tokenStart = -1; | 878 _tokenStart = -1; |
| 844 _lineStarts.add(0); | 879 _lineStarts.add(0); |
| 845 } | 880 } |
| 846 | 881 |
| 847 /** | 882 /** |
| 848 * Return an array containing the offsets of the first character of each line
in the source code. | 883 * Return an array containing the offsets of the first character of each line
in the source code. |
| 849 * | 884 * |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 } | 1895 } |
| 1861 | 1896 |
| 1862 /** | 1897 /** |
| 1863 * Instances of the class `TokenWithComment` represent a normal token that is pr
eceded by | 1898 * Instances of the class `TokenWithComment` represent a normal token that is pr
eceded by |
| 1864 * comments. | 1899 * comments. |
| 1865 */ | 1900 */ |
| 1866 class TokenWithComment extends Token { | 1901 class TokenWithComment extends Token { |
| 1867 /** | 1902 /** |
| 1868 * The first comment in the list of comments that precede this token. | 1903 * The first comment in the list of comments that precede this token. |
| 1869 */ | 1904 */ |
| 1870 final Token _precedingComment; | 1905 Token _precedingComment; |
| 1871 | 1906 |
| 1872 /** | 1907 /** |
| 1873 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 1908 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 1874 * comments reachable from the given comment. | 1909 * comments reachable from the given comment. |
| 1875 * | 1910 * |
| 1876 * @param type the type of the token | 1911 * @param type the type of the token |
| 1877 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1912 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1878 * @param precedingComment the first comment in the list of comments that prec
ede this token | 1913 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 1879 */ | 1914 */ |
| 1880 TokenWithComment(TokenType type, int offset, this._precedingComment) : super(t
ype, offset); | 1915 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t
ype, offset) { |
| 1916 this._precedingComment = precedingComment; |
| 1917 } |
| 1881 | 1918 |
| 1882 @override | 1919 @override |
| 1883 Token copy() => new TokenWithComment(type, offset, _precedingComment); | 1920 Token copy() => new TokenWithComment(type, offset, _precedingComment); |
| 1884 | 1921 |
| 1885 @override | 1922 @override |
| 1886 Token get precedingComments => _precedingComment; | 1923 Token get precedingComments => _precedingComment; |
| 1887 } | 1924 } |
| 1888 | 1925 |
| 1889 /** | 1926 /** |
| 1890 * Instances of the class `Token` represent a token that was scanned from the in
put. Each | 1927 * Instances of the class `Token` represent a token that was scanned from the in
put. Each |
| 1891 * token knows which token follows it, acting as the head of a linked list of to
kens. | 1928 * token knows which token follows it, acting as the head of a linked list of to
kens. |
| 1892 */ | 1929 */ |
| 1893 class Token { | 1930 class Token { |
| 1894 /** | 1931 /** |
| 1895 * The type of the token. | 1932 * The type of the token. |
| 1896 */ | 1933 */ |
| 1897 final TokenType type; | 1934 TokenType type; |
| 1898 | 1935 |
| 1899 /** | 1936 /** |
| 1900 * The offset from the beginning of the file to the first character in the tok
en. | 1937 * The offset from the beginning of the file to the first character in the tok
en. |
| 1901 */ | 1938 */ |
| 1902 int offset = 0; | 1939 int offset = 0; |
| 1903 | 1940 |
| 1904 /** | 1941 /** |
| 1905 * The previous token in the token stream. | 1942 * The previous token in the token stream. |
| 1906 */ | 1943 */ |
| 1907 Token previous; | 1944 Token previous; |
| 1908 | 1945 |
| 1909 /** | 1946 /** |
| 1910 * The next token in the token stream. | 1947 * The next token in the token stream. |
| 1911 */ | 1948 */ |
| 1912 Token _next; | 1949 Token _next; |
| 1913 | 1950 |
| 1914 /** | 1951 /** |
| 1915 * Initialize a newly created token to have the given type and offset. | 1952 * Initialize a newly created token to have the given type and offset. |
| 1916 * | 1953 * |
| 1917 * @param type the type of the token | 1954 * @param type the type of the token |
| 1918 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 1955 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 1919 */ | 1956 */ |
| 1920 Token(this.type, int offset) { | 1957 Token(TokenType type, int offset) { |
| 1958 this.type = type; |
| 1921 this.offset = offset; | 1959 this.offset = offset; |
| 1922 } | 1960 } |
| 1923 | 1961 |
| 1924 /** | 1962 /** |
| 1925 * Return a newly created token that is a copy of this token but that is not a
part of any token | 1963 * Return a newly created token that is a copy of this token but that is not a
part of any token |
| 1926 * stream. | 1964 * stream. |
| 1927 * | 1965 * |
| 1928 * @return a newly created token that is a copy of this token | 1966 * @return a newly created token that is a copy of this token |
| 1929 */ | 1967 */ |
| 1930 Token copy() => new Token(type, offset); | 1968 Token copy() => new Token(type, offset); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 } | 2158 } |
| 2121 | 2159 |
| 2122 /** | 2160 /** |
| 2123 * Instances of the class `BeginTokenWithComment` represent a begin token that i
s preceded by | 2161 * Instances of the class `BeginTokenWithComment` represent a begin token that i
s preceded by |
| 2124 * comments. | 2162 * comments. |
| 2125 */ | 2163 */ |
| 2126 class BeginTokenWithComment extends BeginToken { | 2164 class BeginTokenWithComment extends BeginToken { |
| 2127 /** | 2165 /** |
| 2128 * The first comment in the list of comments that precede this token. | 2166 * The first comment in the list of comments that precede this token. |
| 2129 */ | 2167 */ |
| 2130 final Token _precedingComment; | 2168 Token _precedingComment; |
| 2131 | 2169 |
| 2132 /** | 2170 /** |
| 2133 * Initialize a newly created token to have the given type and offset and to b
e preceded by the | 2171 * Initialize a newly created token to have the given type and offset and to b
e preceded by the |
| 2134 * comments reachable from the given comment. | 2172 * comments reachable from the given comment. |
| 2135 * | 2173 * |
| 2136 * @param type the type of the token | 2174 * @param type the type of the token |
| 2137 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 2175 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 2138 * @param precedingComment the first comment in the list of comments that prec
ede this token | 2176 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 2139 */ | 2177 */ |
| 2140 BeginTokenWithComment(TokenType type, int offset, this._precedingComment) : su
per(type, offset); | 2178 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su
per(type, offset) { |
| 2179 this._precedingComment = precedingComment; |
| 2180 } |
| 2141 | 2181 |
| 2142 @override | 2182 @override |
| 2143 Token copy() => new BeginTokenWithComment(type, offset, copyComments(_precedin
gComment)); | 2183 Token copy() => new BeginTokenWithComment(type, offset, copyComments(_precedin
gComment)); |
| 2144 | 2184 |
| 2145 @override | 2185 @override |
| 2146 Token get precedingComments => _precedingComment; | 2186 Token get precedingComments => _precedingComment; |
| 2147 | 2187 |
| 2148 @override | 2188 @override |
| 2149 void applyDelta(int delta) { | 2189 void applyDelta(int delta) { |
| 2150 super.applyDelta(delta); | 2190 super.applyDelta(delta); |
| 2151 Token token = _precedingComment; | 2191 Token token = _precedingComment; |
| 2152 while (token != null) { | 2192 while (token != null) { |
| 2153 token.applyDelta(delta); | 2193 token.applyDelta(delta); |
| 2154 token = token.next; | 2194 token = token.next; |
| 2155 } | 2195 } |
| 2156 } | 2196 } |
| 2157 } | 2197 } |
| 2158 | 2198 |
| 2159 /** | 2199 /** |
| 2160 * Instances of the class `KeywordToken` represent a keyword in the language. | 2200 * Instances of the class `KeywordToken` represent a keyword in the language. |
| 2161 */ | 2201 */ |
| 2162 class KeywordToken extends Token { | 2202 class KeywordToken extends Token { |
| 2163 /** | 2203 /** |
| 2164 * The keyword being represented by this token. | 2204 * The keyword being represented by this token. |
| 2165 */ | 2205 */ |
| 2166 final Keyword keyword; | 2206 Keyword keyword; |
| 2167 | 2207 |
| 2168 /** | 2208 /** |
| 2169 * Initialize a newly created token to represent the given keyword. | 2209 * Initialize a newly created token to represent the given keyword. |
| 2170 * | 2210 * |
| 2171 * @param keyword the keyword being represented by this token | 2211 * @param keyword the keyword being represented by this token |
| 2172 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 2212 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 2173 */ | 2213 */ |
| 2174 KeywordToken(this.keyword, int offset) : super(TokenType.KEYWORD, offset); | 2214 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { |
| 2215 this.keyword = keyword; |
| 2216 } |
| 2175 | 2217 |
| 2176 @override | 2218 @override |
| 2177 Token copy() => new KeywordToken(keyword, offset); | 2219 Token copy() => new KeywordToken(keyword, offset); |
| 2178 | 2220 |
| 2179 @override | 2221 @override |
| 2180 String get lexeme => keyword.syntax; | 2222 String get lexeme => keyword.syntax; |
| 2181 | 2223 |
| 2182 @override | 2224 @override |
| 2183 Keyword value() => keyword; | 2225 Keyword value() => keyword; |
| 2184 } | 2226 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2207 Token copy() => new BeginToken(type, offset); | 2249 Token copy() => new BeginToken(type, offset); |
| 2208 } | 2250 } |
| 2209 | 2251 |
| 2210 /** | 2252 /** |
| 2211 * The enumeration `TokenClass` represents classes (or groups) of tokens with a
similar use. | 2253 * The enumeration `TokenClass` represents classes (or groups) of tokens with a
similar use. |
| 2212 */ | 2254 */ |
| 2213 class TokenClass extends Enum<TokenClass> { | 2255 class TokenClass extends Enum<TokenClass> { |
| 2214 /** | 2256 /** |
| 2215 * A value used to indicate that the token type is not part of any specific cl
ass of token. | 2257 * A value used to indicate that the token type is not part of any specific cl
ass of token. |
| 2216 */ | 2258 */ |
| 2217 static const TokenClass NO_CLASS = const TokenClass.con1('NO_CLASS', 0); | 2259 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); |
| 2218 | 2260 |
| 2219 /** | 2261 /** |
| 2220 * A value used to indicate that the token type is an additive operator. | 2262 * A value used to indicate that the token type is an additive operator. |
| 2221 */ | 2263 */ |
| 2222 static const TokenClass ADDITIVE_OPERATOR = const TokenClass.con2('ADDITIVE_OP
ERATOR', 1, 12); | 2264 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER
ATOR', 1, 12); |
| 2223 | 2265 |
| 2224 /** | 2266 /** |
| 2225 * A value used to indicate that the token type is an assignment operator. | 2267 * A value used to indicate that the token type is an assignment operator. |
| 2226 */ | 2268 */ |
| 2227 static const TokenClass ASSIGNMENT_OPERATOR = const TokenClass.con2('ASSIGNMEN
T_OPERATOR', 2, 1); | 2269 static final TokenClass ASSIGNMENT_OPERATOR = new TokenClass.con2('ASSIGNMENT_
OPERATOR', 2, 1); |
| 2228 | 2270 |
| 2229 /** | 2271 /** |
| 2230 * A value used to indicate that the token type is a bitwise-and operator. | 2272 * A value used to indicate that the token type is a bitwise-and operator. |
| 2231 */ | 2273 */ |
| 2232 static const TokenClass BITWISE_AND_OPERATOR = const TokenClass.con2('BITWISE_
AND_OPERATOR', 3, 10); | 2274 static final TokenClass BITWISE_AND_OPERATOR = new TokenClass.con2('BITWISE_AN
D_OPERATOR', 3, 10); |
| 2233 | 2275 |
| 2234 /** | 2276 /** |
| 2235 * A value used to indicate that the token type is a bitwise-or operator. | 2277 * A value used to indicate that the token type is a bitwise-or operator. |
| 2236 */ | 2278 */ |
| 2237 static const TokenClass BITWISE_OR_OPERATOR = const TokenClass.con2('BITWISE_O
R_OPERATOR', 4, 8); | 2279 static final TokenClass BITWISE_OR_OPERATOR = new TokenClass.con2('BITWISE_OR_
OPERATOR', 4, 8); |
| 2238 | 2280 |
| 2239 /** | 2281 /** |
| 2240 * A value used to indicate that the token type is a bitwise-xor operator. | 2282 * A value used to indicate that the token type is a bitwise-xor operator. |
| 2241 */ | 2283 */ |
| 2242 static const TokenClass BITWISE_XOR_OPERATOR = const TokenClass.con2('BITWISE_
XOR_OPERATOR', 5, 9); | 2284 static final TokenClass BITWISE_XOR_OPERATOR = new TokenClass.con2('BITWISE_XO
R_OPERATOR', 5, 9); |
| 2243 | 2285 |
| 2244 /** | 2286 /** |
| 2245 * A value used to indicate that the token type is a cascade operator. | 2287 * A value used to indicate that the token type is a cascade operator. |
| 2246 */ | 2288 */ |
| 2247 static const TokenClass CASCADE_OPERATOR = const TokenClass.con2('CASCADE_OPER
ATOR', 6, 2); | 2289 static final TokenClass CASCADE_OPERATOR = new TokenClass.con2('CASCADE_OPERAT
OR', 6, 2); |
| 2248 | 2290 |
| 2249 /** | 2291 /** |
| 2250 * A value used to indicate that the token type is a conditional operator. | 2292 * A value used to indicate that the token type is a conditional operator. |
| 2251 */ | 2293 */ |
| 2252 static const TokenClass CONDITIONAL_OPERATOR = const TokenClass.con2('CONDITIO
NAL_OPERATOR', 7, 3); | 2294 static final TokenClass CONDITIONAL_OPERATOR = new TokenClass.con2('CONDITIONA
L_OPERATOR', 7, 3); |
| 2253 | 2295 |
| 2254 /** | 2296 /** |
| 2255 * A value used to indicate that the token type is an equality operator. | 2297 * A value used to indicate that the token type is an equality operator. |
| 2256 */ | 2298 */ |
| 2257 static const TokenClass EQUALITY_OPERATOR = const TokenClass.con2('EQUALITY_OP
ERATOR', 8, 6); | 2299 static final TokenClass EQUALITY_OPERATOR = new TokenClass.con2('EQUALITY_OPER
ATOR', 8, 6); |
| 2258 | 2300 |
| 2259 /** | 2301 /** |
| 2260 * A value used to indicate that the token type is a logical-and operator. | 2302 * A value used to indicate that the token type is a logical-and operator. |
| 2261 */ | 2303 */ |
| 2262 static const TokenClass LOGICAL_AND_OPERATOR = const TokenClass.con2('LOGICAL_
AND_OPERATOR', 9, 5); | 2304 static final TokenClass LOGICAL_AND_OPERATOR = new TokenClass.con2('LOGICAL_AN
D_OPERATOR', 9, 5); |
| 2263 | 2305 |
| 2264 /** | 2306 /** |
| 2265 * A value used to indicate that the token type is a logical-or operator. | 2307 * A value used to indicate that the token type is a logical-or operator. |
| 2266 */ | 2308 */ |
| 2267 static const TokenClass LOGICAL_OR_OPERATOR = const TokenClass.con2('LOGICAL_O
R_OPERATOR', 10, 4); | 2309 static final TokenClass LOGICAL_OR_OPERATOR = new TokenClass.con2('LOGICAL_OR_
OPERATOR', 10, 4); |
| 2268 | 2310 |
| 2269 /** | 2311 /** |
| 2270 * A value used to indicate that the token type is a multiplicative operator. | 2312 * A value used to indicate that the token type is a multiplicative operator. |
| 2271 */ | 2313 */ |
| 2272 static const TokenClass MULTIPLICATIVE_OPERATOR = const TokenClass.con2('MULTI
PLICATIVE_OPERATOR', 11, 13); | 2314 static final TokenClass MULTIPLICATIVE_OPERATOR = new TokenClass.con2('MULTIPL
ICATIVE_OPERATOR', 11, 13); |
| 2273 | 2315 |
| 2274 /** | 2316 /** |
| 2275 * A value used to indicate that the token type is a relational operator. | 2317 * A value used to indicate that the token type is a relational operator. |
| 2276 */ | 2318 */ |
| 2277 static const TokenClass RELATIONAL_OPERATOR = const TokenClass.con2('RELATIONA
L_OPERATOR', 12, 7); | 2319 static final TokenClass RELATIONAL_OPERATOR = new TokenClass.con2('RELATIONAL_
OPERATOR', 12, 7); |
| 2278 | 2320 |
| 2279 /** | 2321 /** |
| 2280 * A value used to indicate that the token type is a shift operator. | 2322 * A value used to indicate that the token type is a shift operator. |
| 2281 */ | 2323 */ |
| 2282 static const TokenClass SHIFT_OPERATOR = const TokenClass.con2('SHIFT_OPERATOR
', 13, 11); | 2324 static final TokenClass SHIFT_OPERATOR = new TokenClass.con2('SHIFT_OPERATOR',
13, 11); |
| 2283 | 2325 |
| 2284 /** | 2326 /** |
| 2285 * A value used to indicate that the token type is a unary operator. | 2327 * A value used to indicate that the token type is a unary operator. |
| 2286 */ | 2328 */ |
| 2287 static const TokenClass UNARY_POSTFIX_OPERATOR = const TokenClass.con2('UNARY_
POSTFIX_OPERATOR', 14, 15); | 2329 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO
STFIX_OPERATOR', 14, 15); |
| 2288 | 2330 |
| 2289 /** | 2331 /** |
| 2290 * A value used to indicate that the token type is a unary operator. | 2332 * A value used to indicate that the token type is a unary operator. |
| 2291 */ | 2333 */ |
| 2292 static const TokenClass UNARY_PREFIX_OPERATOR = const TokenClass.con2('UNARY_P
REFIX_OPERATOR', 15, 14); | 2334 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE
FIX_OPERATOR', 15, 14); |
| 2293 | 2335 |
| 2294 static const List<TokenClass> values = const [ | 2336 static final List<TokenClass> values = [ |
| 2295 NO_CLASS, | 2337 NO_CLASS, |
| 2296 ADDITIVE_OPERATOR, | 2338 ADDITIVE_OPERATOR, |
| 2297 ASSIGNMENT_OPERATOR, | 2339 ASSIGNMENT_OPERATOR, |
| 2298 BITWISE_AND_OPERATOR, | 2340 BITWISE_AND_OPERATOR, |
| 2299 BITWISE_OR_OPERATOR, | 2341 BITWISE_OR_OPERATOR, |
| 2300 BITWISE_XOR_OPERATOR, | 2342 BITWISE_XOR_OPERATOR, |
| 2301 CASCADE_OPERATOR, | 2343 CASCADE_OPERATOR, |
| 2302 CONDITIONAL_OPERATOR, | 2344 CONDITIONAL_OPERATOR, |
| 2303 EQUALITY_OPERATOR, | 2345 EQUALITY_OPERATOR, |
| 2304 LOGICAL_AND_OPERATOR, | 2346 LOGICAL_AND_OPERATOR, |
| 2305 LOGICAL_OR_OPERATOR, | 2347 LOGICAL_OR_OPERATOR, |
| 2306 MULTIPLICATIVE_OPERATOR, | 2348 MULTIPLICATIVE_OPERATOR, |
| 2307 RELATIONAL_OPERATOR, | 2349 RELATIONAL_OPERATOR, |
| 2308 SHIFT_OPERATOR, | 2350 SHIFT_OPERATOR, |
| 2309 UNARY_POSTFIX_OPERATOR, | 2351 UNARY_POSTFIX_OPERATOR, |
| 2310 UNARY_PREFIX_OPERATOR]; | 2352 UNARY_PREFIX_OPERATOR]; |
| 2311 | 2353 |
| 2312 /** | 2354 /** |
| 2313 * The precedence of tokens of this class, or `0` if the such tokens do not re
present an | 2355 * The precedence of tokens of this class, or `0` if the such tokens do not re
present an |
| 2314 * operator. | 2356 * operator. |
| 2315 */ | 2357 */ |
| 2316 final int precedence; | 2358 int _precedence = 0; |
| 2317 | 2359 |
| 2318 const TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0); | 2360 TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0); |
| 2319 | 2361 |
| 2320 const TokenClass.con2(String name, int ordinal, this.precedence) : super(name,
ordinal); | 2362 TokenClass.con2(String name, int ordinal, int precedence) : super(name, ordina
l) { |
| 2363 this._precedence = precedence; |
| 2364 } |
| 2365 |
| 2366 /** |
| 2367 * Return the precedence of tokens of this class, or `0` if the such tokens do
not represent |
| 2368 * an operator. |
| 2369 * |
| 2370 * @return the precedence of tokens of this class |
| 2371 */ |
| 2372 int get precedence => _precedence; |
| 2321 } | 2373 } |
| 2322 | 2374 |
| 2323 /** | 2375 /** |
| 2324 * Instances of the class `KeywordTokenWithComment` implement a keyword token th
at is preceded | 2376 * Instances of the class `KeywordTokenWithComment` implement a keyword token th
at is preceded |
| 2325 * by comments. | 2377 * by comments. |
| 2326 */ | 2378 */ |
| 2327 class KeywordTokenWithComment extends KeywordToken { | 2379 class KeywordTokenWithComment extends KeywordToken { |
| 2328 /** | 2380 /** |
| 2329 * The first comment in the list of comments that precede this token. | 2381 * The first comment in the list of comments that precede this token. |
| 2330 */ | 2382 */ |
| 2331 final Token _precedingComment; | 2383 Token _precedingComment; |
| 2332 | 2384 |
| 2333 /** | 2385 /** |
| 2334 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the | 2386 * Initialize a newly created token to to represent the given keyword and to b
e preceded by the |
| 2335 * comments reachable from the given comment. | 2387 * comments reachable from the given comment. |
| 2336 * | 2388 * |
| 2337 * @param keyword the keyword being represented by this token | 2389 * @param keyword the keyword being represented by this token |
| 2338 * @param offset the offset from the beginning of the file to the first charac
ter in the token | 2390 * @param offset the offset from the beginning of the file to the first charac
ter in the token |
| 2339 * @param precedingComment the first comment in the list of comments that prec
ede this token | 2391 * @param precedingComment the first comment in the list of comments that prec
ede this token |
| 2340 */ | 2392 */ |
| 2341 KeywordTokenWithComment(Keyword keyword, int offset, this._precedingComment) :
super(keyword, offset); | 2393 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) :
super(keyword, offset) { |
| 2394 this._precedingComment = precedingComment; |
| 2395 } |
| 2342 | 2396 |
| 2343 @override | 2397 @override |
| 2344 Token copy() => new KeywordTokenWithComment(keyword, offset, copyComments(_pre
cedingComment)); | 2398 Token copy() => new KeywordTokenWithComment(keyword, offset, copyComments(_pre
cedingComment)); |
| 2345 | 2399 |
| 2346 @override | 2400 @override |
| 2347 Token get precedingComments => _precedingComment; | 2401 Token get precedingComments => _precedingComment; |
| 2348 | 2402 |
| 2349 @override | 2403 @override |
| 2350 void applyDelta(int delta) { | 2404 void applyDelta(int delta) { |
| 2351 super.applyDelta(delta); | 2405 super.applyDelta(delta); |
| 2352 Token token = _precedingComment; | 2406 Token token = _precedingComment; |
| 2353 while (token != null) { | 2407 while (token != null) { |
| 2354 token.applyDelta(delta); | 2408 token.applyDelta(delta); |
| 2355 token = token.next; | 2409 token = token.next; |
| 2356 } | 2410 } |
| 2357 } | 2411 } |
| 2358 } | 2412 } |
| 2359 | 2413 |
| 2360 /** | 2414 /** |
| 2361 * The enumeration `TokenType` defines the types of tokens that can be returned
by the | 2415 * The enumeration `TokenType` defines the types of tokens that can be returned
by the |
| 2362 * scanner. | 2416 * scanner. |
| 2363 */ | 2417 */ |
| 2364 class TokenType extends Enum<TokenType> { | 2418 class TokenType extends Enum<TokenType> { |
| 2365 /** | 2419 /** |
| 2366 * The type of the token that marks the end of the input. | 2420 * The type of the token that marks the end of the input. |
| 2367 */ | 2421 */ |
| 2368 static const TokenType EOF = const TokenType_EOF('EOF', 0, TokenClass.NO_CLASS
, ""); | 2422 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); |
| 2369 | 2423 |
| 2370 static const TokenType DOUBLE = const TokenType.con1('DOUBLE', 1); | 2424 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); |
| 2371 | 2425 |
| 2372 static const TokenType HEXADECIMAL = const TokenType.con1('HEXADECIMAL', 2); | 2426 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); |
| 2373 | 2427 |
| 2374 static const TokenType IDENTIFIER = const TokenType.con1('IDENTIFIER', 3); | 2428 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3); |
| 2375 | 2429 |
| 2376 static const TokenType INT = const TokenType.con1('INT', 4); | 2430 static final TokenType INT = new TokenType.con1('INT', 4); |
| 2377 | 2431 |
| 2378 static const TokenType KEYWORD = const TokenType.con1('KEYWORD', 5); | 2432 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5); |
| 2379 | 2433 |
| 2380 static const TokenType MULTI_LINE_COMMENT = const TokenType.con1('MULTI_LINE_C
OMMENT', 6); | 2434 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM
MENT', 6); |
| 2381 | 2435 |
| 2382 static const TokenType SCRIPT_TAG = const TokenType.con1('SCRIPT_TAG', 7); | 2436 static final TokenType SCRIPT_TAG = new TokenType.con1('SCRIPT_TAG', 7); |
| 2383 | 2437 |
| 2384 static const TokenType SINGLE_LINE_COMMENT = const TokenType.con1('SINGLE_LINE
_COMMENT', 8); | 2438 static final TokenType SINGLE_LINE_COMMENT = new TokenType.con1('SINGLE_LINE_C
OMMENT', 8); |
| 2385 | 2439 |
| 2386 static const TokenType STRING = const TokenType.con1('STRING', 9); | 2440 static final TokenType STRING = new TokenType.con1('STRING', 9); |
| 2387 | 2441 |
| 2388 static const TokenType AMPERSAND = const TokenType.con2('AMPERSAND', 10, Token
Class.BITWISE_AND_OPERATOR, "&"); | 2442 static final TokenType AMPERSAND = new TokenType.con2('AMPERSAND', 10, TokenCl
ass.BITWISE_AND_OPERATOR, "&"); |
| 2389 | 2443 |
| 2390 static const TokenType AMPERSAND_AMPERSAND = const TokenType.con2('AMPERSAND_A
MPERSAND', 11, TokenClass.LOGICAL_AND_OPERATOR, "&&"); | 2444 static final TokenType AMPERSAND_AMPERSAND = new TokenType.con2('AMPERSAND_AMP
ERSAND', 11, TokenClass.LOGICAL_AND_OPERATOR, "&&"); |
| 2391 | 2445 |
| 2392 static const TokenType AMPERSAND_EQ = const TokenType.con2('AMPERSAND_EQ', 12,
TokenClass.ASSIGNMENT_OPERATOR, "&="); | 2446 static final TokenType AMPERSAND_EQ = new TokenType.con2('AMPERSAND_EQ', 12, T
okenClass.ASSIGNMENT_OPERATOR, "&="); |
| 2393 | 2447 |
| 2394 static const TokenType AT = const TokenType.con2('AT', 13, TokenClass.NO_CLASS
, "@"); | 2448 static final TokenType AT = new TokenType.con2('AT', 13, null, "@"); |
| 2395 | 2449 |
| 2396 static const TokenType BANG = const TokenType.con2('BANG', 14, TokenClass.UNAR
Y_PREFIX_OPERATOR, "!"); | 2450 static final TokenType BANG = new TokenType.con2('BANG', 14, TokenClass.UNARY_
PREFIX_OPERATOR, "!"); |
| 2397 | 2451 |
| 2398 static const TokenType BANG_EQ = const TokenType.con2('BANG_EQ', 15, TokenClas
s.EQUALITY_OPERATOR, "!="); | 2452 static final TokenType BANG_EQ = new TokenType.con2('BANG_EQ', 15, TokenClass.
EQUALITY_OPERATOR, "!="); |
| 2399 | 2453 |
| 2400 static const TokenType BAR = const TokenType.con2('BAR', 16, TokenClass.BITWIS
E_OR_OPERATOR, "|"); | 2454 static final TokenType BAR = new TokenType.con2('BAR', 16, TokenClass.BITWISE_
OR_OPERATOR, "|"); |
| 2401 | 2455 |
| 2402 static const TokenType BAR_BAR = const TokenType.con2('BAR_BAR', 17, TokenClas
s.LOGICAL_OR_OPERATOR, "||"); | 2456 static final TokenType BAR_BAR = new TokenType.con2('BAR_BAR', 17, TokenClass.
LOGICAL_OR_OPERATOR, "||"); |
| 2403 | 2457 |
| 2404 static const TokenType BAR_EQ = const TokenType.con2('BAR_EQ', 18, TokenClass.
ASSIGNMENT_OPERATOR, "|="); | 2458 static final TokenType BAR_EQ = new TokenType.con2('BAR_EQ', 18, TokenClass.AS
SIGNMENT_OPERATOR, "|="); |
| 2405 | 2459 |
| 2406 static const TokenType COLON = const TokenType.con2('COLON', 19, TokenClass.NO
_CLASS, ":"); | 2460 static final TokenType COLON = new TokenType.con2('COLON', 19, null, ":"); |
| 2407 | 2461 |
| 2408 static const TokenType COMMA = const TokenType.con2('COMMA', 20, TokenClass.NO
_CLASS, ","); | 2462 static final TokenType COMMA = new TokenType.con2('COMMA', 20, null, ","); |
| 2409 | 2463 |
| 2410 static const TokenType CARET = const TokenType.con2('CARET', 21, TokenClass.BI
TWISE_XOR_OPERATOR, "^"); | 2464 static final TokenType CARET = new TokenType.con2('CARET', 21, TokenClass.BITW
ISE_XOR_OPERATOR, "^"); |
| 2411 | 2465 |
| 2412 static const TokenType CARET_EQ = const TokenType.con2('CARET_EQ', 22, TokenCl
ass.ASSIGNMENT_OPERATOR, "^="); | 2466 static final TokenType CARET_EQ = new TokenType.con2('CARET_EQ', 22, TokenClas
s.ASSIGNMENT_OPERATOR, "^="); |
| 2413 | 2467 |
| 2414 static const TokenType CLOSE_CURLY_BRACKET = const TokenType.con2('CLOSE_CURLY
_BRACKET', 23, TokenClass.NO_CLASS, "}"); | 2468 static final TokenType CLOSE_CURLY_BRACKET = new TokenType.con2('CLOSE_CURLY_B
RACKET', 23, null, "}"); |
| 2415 | 2469 |
| 2416 static const TokenType CLOSE_PAREN = const TokenType.con2('CLOSE_PAREN', 24, T
okenClass.NO_CLASS, ")"); | 2470 static final TokenType CLOSE_PAREN = new TokenType.con2('CLOSE_PAREN', 24, nul
l, ")"); |
| 2417 | 2471 |
| 2418 static const TokenType CLOSE_SQUARE_BRACKET = const TokenType.con2('CLOSE_SQUA
RE_BRACKET', 25, TokenClass.NO_CLASS, "]"); | 2472 static final TokenType CLOSE_SQUARE_BRACKET = new TokenType.con2('CLOSE_SQUARE
_BRACKET', 25, null, "]"); |
| 2419 | 2473 |
| 2420 static const TokenType EQ = const TokenType.con2('EQ', 26, TokenClass.ASSIGNME
NT_OPERATOR, "="); | 2474 static final TokenType EQ = new TokenType.con2('EQ', 26, TokenClass.ASSIGNMENT
_OPERATOR, "="); |
| 2421 | 2475 |
| 2422 static const TokenType EQ_EQ = const TokenType.con2('EQ_EQ', 27, TokenClass.EQ
UALITY_OPERATOR, "=="); | 2476 static final TokenType EQ_EQ = new TokenType.con2('EQ_EQ', 27, TokenClass.EQUA
LITY_OPERATOR, "=="); |
| 2423 | 2477 |
| 2424 static const TokenType FUNCTION = const TokenType.con2('FUNCTION', 28, TokenCl
ass.NO_CLASS, "=>"); | 2478 static final TokenType FUNCTION = new TokenType.con2('FUNCTION', 28, null, "=>
"); |
| 2425 | 2479 |
| 2426 static const TokenType GT = const TokenType.con2('GT', 29, TokenClass.RELATION
AL_OPERATOR, ">"); | 2480 static final TokenType GT = new TokenType.con2('GT', 29, TokenClass.RELATIONAL
_OPERATOR, ">"); |
| 2427 | 2481 |
| 2428 static const TokenType GT_EQ = const TokenType.con2('GT_EQ', 30, TokenClass.RE
LATIONAL_OPERATOR, ">="); | 2482 static final TokenType GT_EQ = new TokenType.con2('GT_EQ', 30, TokenClass.RELA
TIONAL_OPERATOR, ">="); |
| 2429 | 2483 |
| 2430 static const TokenType GT_GT = const TokenType.con2('GT_GT', 31, TokenClass.SH
IFT_OPERATOR, ">>"); | 2484 static final TokenType GT_GT = new TokenType.con2('GT_GT', 31, TokenClass.SHIF
T_OPERATOR, ">>"); |
| 2431 | 2485 |
| 2432 static const TokenType GT_GT_EQ = const TokenType.con2('GT_GT_EQ', 32, TokenCl
ass.ASSIGNMENT_OPERATOR, ">>="); | 2486 static final TokenType GT_GT_EQ = new TokenType.con2('GT_GT_EQ', 32, TokenClas
s.ASSIGNMENT_OPERATOR, ">>="); |
| 2433 | 2487 |
| 2434 static const TokenType HASH = const TokenType.con2('HASH', 33, TokenClass.NO_C
LASS, "#"); | 2488 static final TokenType HASH = new TokenType.con2('HASH', 33, null, "#"); |
| 2435 | 2489 |
| 2436 static const TokenType INDEX = const TokenType.con2('INDEX', 34, TokenClass.UN
ARY_POSTFIX_OPERATOR, "[]"); | 2490 static final TokenType INDEX = new TokenType.con2('INDEX', 34, TokenClass.UNAR
Y_POSTFIX_OPERATOR, "[]"); |
| 2437 | 2491 |
| 2438 static const TokenType INDEX_EQ = const TokenType.con2('INDEX_EQ', 35, TokenCl
ass.UNARY_POSTFIX_OPERATOR, "[]="); | 2492 static final TokenType INDEX_EQ = new TokenType.con2('INDEX_EQ', 35, TokenClas
s.UNARY_POSTFIX_OPERATOR, "[]="); |
| 2439 | 2493 |
| 2440 static const TokenType IS = const TokenType.con2('IS', 36, TokenClass.RELATION
AL_OPERATOR, "is"); | 2494 static final TokenType IS = new TokenType.con2('IS', 36, TokenClass.RELATIONAL
_OPERATOR, "is"); |
| 2441 | 2495 |
| 2442 static const TokenType LT = const TokenType.con2('LT', 37, TokenClass.RELATION
AL_OPERATOR, "<"); | 2496 static final TokenType LT = new TokenType.con2('LT', 37, TokenClass.RELATIONAL
_OPERATOR, "<"); |
| 2443 | 2497 |
| 2444 static const TokenType LT_EQ = const TokenType.con2('LT_EQ', 38, TokenClass.RE
LATIONAL_OPERATOR, "<="); | 2498 static final TokenType LT_EQ = new TokenType.con2('LT_EQ', 38, TokenClass.RELA
TIONAL_OPERATOR, "<="); |
| 2445 | 2499 |
| 2446 static const TokenType LT_LT = const TokenType.con2('LT_LT', 39, TokenClass.SH
IFT_OPERATOR, "<<"); | 2500 static final TokenType LT_LT = new TokenType.con2('LT_LT', 39, TokenClass.SHIF
T_OPERATOR, "<<"); |
| 2447 | 2501 |
| 2448 static const TokenType LT_LT_EQ = const TokenType.con2('LT_LT_EQ', 40, TokenCl
ass.ASSIGNMENT_OPERATOR, "<<="); | 2502 static final TokenType LT_LT_EQ = new TokenType.con2('LT_LT_EQ', 40, TokenClas
s.ASSIGNMENT_OPERATOR, "<<="); |
| 2449 | 2503 |
| 2450 static const TokenType MINUS = const TokenType.con2('MINUS', 41, TokenClass.AD
DITIVE_OPERATOR, "-"); | 2504 static final TokenType MINUS = new TokenType.con2('MINUS', 41, TokenClass.ADDI
TIVE_OPERATOR, "-"); |
| 2451 | 2505 |
| 2452 static const TokenType MINUS_EQ = const TokenType.con2('MINUS_EQ', 42, TokenCl
ass.ASSIGNMENT_OPERATOR, "-="); | 2506 static final TokenType MINUS_EQ = new TokenType.con2('MINUS_EQ', 42, TokenClas
s.ASSIGNMENT_OPERATOR, "-="); |
| 2453 | 2507 |
| 2454 static const TokenType MINUS_MINUS = const TokenType.con2('MINUS_MINUS', 43, T
okenClass.UNARY_PREFIX_OPERATOR, "--"); | 2508 static final TokenType MINUS_MINUS = new TokenType.con2('MINUS_MINUS', 43, Tok
enClass.UNARY_PREFIX_OPERATOR, "--"); |
| 2455 | 2509 |
| 2456 static const TokenType OPEN_CURLY_BRACKET = const TokenType.con2('OPEN_CURLY_B
RACKET', 44, TokenClass.NO_CLASS, "{"); | 2510 static final TokenType OPEN_CURLY_BRACKET = new TokenType.con2('OPEN_CURLY_BRA
CKET', 44, null, "{"); |
| 2457 | 2511 |
| 2458 static const TokenType OPEN_PAREN = const TokenType.con2('OPEN_PAREN', 45, Tok
enClass.UNARY_POSTFIX_OPERATOR, "("); | 2512 static final TokenType OPEN_PAREN = new TokenType.con2('OPEN_PAREN', 45, Token
Class.UNARY_POSTFIX_OPERATOR, "("); |
| 2459 | 2513 |
| 2460 static const TokenType OPEN_SQUARE_BRACKET = const TokenType.con2('OPEN_SQUARE
_BRACKET', 46, TokenClass.UNARY_POSTFIX_OPERATOR, "["); | 2514 static final TokenType OPEN_SQUARE_BRACKET = new TokenType.con2('OPEN_SQUARE_B
RACKET', 46, TokenClass.UNARY_POSTFIX_OPERATOR, "["); |
| 2461 | 2515 |
| 2462 static const TokenType PERCENT = const TokenType.con2('PERCENT', 47, TokenClas
s.MULTIPLICATIVE_OPERATOR, "%"); | 2516 static final TokenType PERCENT = new TokenType.con2('PERCENT', 47, TokenClass.
MULTIPLICATIVE_OPERATOR, "%"); |
| 2463 | 2517 |
| 2464 static const TokenType PERCENT_EQ = const TokenType.con2('PERCENT_EQ', 48, Tok
enClass.ASSIGNMENT_OPERATOR, "%="); | 2518 static final TokenType PERCENT_EQ = new TokenType.con2('PERCENT_EQ', 48, Token
Class.ASSIGNMENT_OPERATOR, "%="); |
| 2465 | 2519 |
| 2466 static const TokenType PERIOD = const TokenType.con2('PERIOD', 49, TokenClass.
UNARY_POSTFIX_OPERATOR, "."); | 2520 static final TokenType PERIOD = new TokenType.con2('PERIOD', 49, TokenClass.UN
ARY_POSTFIX_OPERATOR, "."); |
| 2467 | 2521 |
| 2468 static const TokenType PERIOD_PERIOD = const TokenType.con2('PERIOD_PERIOD', 5
0, TokenClass.CASCADE_OPERATOR, ".."); | 2522 static final TokenType PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIOD', 50,
TokenClass.CASCADE_OPERATOR, ".."); |
| 2469 | 2523 |
| 2470 static const TokenType PLUS = const TokenType.con2('PLUS', 51, TokenClass.ADDI
TIVE_OPERATOR, "+"); | 2524 static final TokenType PLUS = new TokenType.con2('PLUS', 51, TokenClass.ADDITI
VE_OPERATOR, "+"); |
| 2471 | 2525 |
| 2472 static const TokenType PLUS_EQ = const TokenType.con2('PLUS_EQ', 52, TokenClas
s.ASSIGNMENT_OPERATOR, "+="); | 2526 static final TokenType PLUS_EQ = new TokenType.con2('PLUS_EQ', 52, TokenClass.
ASSIGNMENT_OPERATOR, "+="); |
| 2473 | 2527 |
| 2474 static const TokenType PLUS_PLUS = const TokenType.con2('PLUS_PLUS', 53, Token
Class.UNARY_PREFIX_OPERATOR, "++"); | 2528 static final TokenType PLUS_PLUS = new TokenType.con2('PLUS_PLUS', 53, TokenCl
ass.UNARY_PREFIX_OPERATOR, "++"); |
| 2475 | 2529 |
| 2476 static const TokenType QUESTION = const TokenType.con2('QUESTION', 54, TokenCl
ass.CONDITIONAL_OPERATOR, "?"); | 2530 static final TokenType QUESTION = new TokenType.con2('QUESTION', 54, TokenClas
s.CONDITIONAL_OPERATOR, "?"); |
| 2477 | 2531 |
| 2478 static const TokenType SEMICOLON = const TokenType.con2('SEMICOLON', 55, Token
Class.NO_CLASS, ";"); | 2532 static final TokenType SEMICOLON = new TokenType.con2('SEMICOLON', 55, null, "
;"); |
| 2479 | 2533 |
| 2480 static const TokenType SLASH = const TokenType.con2('SLASH', 56, TokenClass.MU
LTIPLICATIVE_OPERATOR, "/"); | 2534 static final TokenType SLASH = new TokenType.con2('SLASH', 56, TokenClass.MULT
IPLICATIVE_OPERATOR, "/"); |
| 2481 | 2535 |
| 2482 static const TokenType SLASH_EQ = const TokenType.con2('SLASH_EQ', 57, TokenCl
ass.ASSIGNMENT_OPERATOR, "/="); | 2536 static final TokenType SLASH_EQ = new TokenType.con2('SLASH_EQ', 57, TokenClas
s.ASSIGNMENT_OPERATOR, "/="); |
| 2483 | 2537 |
| 2484 static const TokenType STAR = const TokenType.con2('STAR', 58, TokenClass.MULT
IPLICATIVE_OPERATOR, "*"); | 2538 static final TokenType STAR = new TokenType.con2('STAR', 58, TokenClass.MULTIP
LICATIVE_OPERATOR, "*"); |
| 2485 | 2539 |
| 2486 static const TokenType STAR_EQ = const TokenType.con2('STAR_EQ', 59, TokenClas
s.ASSIGNMENT_OPERATOR, "*="); | 2540 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass.
ASSIGNMENT_OPERATOR, "*="); |
| 2487 | 2541 |
| 2488 static const TokenType STRING_INTERPOLATION_EXPRESSION = const TokenType.con2(
'STRING_INTERPOLATION_EXPRESSION', 60, TokenClass.NO_CLASS, "\${"); | 2542 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S
TRING_INTERPOLATION_EXPRESSION', 60, null, "\${"); |
| 2489 | 2543 |
| 2490 static const TokenType STRING_INTERPOLATION_IDENTIFIER = const TokenType.con2(
'STRING_INTERPOLATION_IDENTIFIER', 61, TokenClass.NO_CLASS, "\$"); | 2544 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S
TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$"); |
| 2491 | 2545 |
| 2492 static const TokenType TILDE = const TokenType.con2('TILDE', 62, TokenClass.UN
ARY_PREFIX_OPERATOR, "~"); | 2546 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR
Y_PREFIX_OPERATOR, "~"); |
| 2493 | 2547 |
| 2494 static const TokenType TILDE_SLASH = const TokenType.con2('TILDE_SLASH', 63, T
okenClass.MULTIPLICATIVE_OPERATOR, "~/"); | 2548 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok
enClass.MULTIPLICATIVE_OPERATOR, "~/"); |
| 2495 | 2549 |
| 2496 static const TokenType TILDE_SLASH_EQ = const TokenType.con2('TILDE_SLASH_EQ',
64, TokenClass.ASSIGNMENT_OPERATOR, "~/="); | 2550 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6
4, TokenClass.ASSIGNMENT_OPERATOR, "~/="); |
| 2497 | 2551 |
| 2498 static const TokenType BACKPING = const TokenType.con2('BACKPING', 65, TokenCl
ass.NO_CLASS, "`"); | 2552 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`"
); |
| 2499 | 2553 |
| 2500 static const TokenType BACKSLASH = const TokenType.con2('BACKSLASH', 66, Token
Class.NO_CLASS, "\\"); | 2554 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, "
\\"); |
| 2501 | 2555 |
| 2502 static const TokenType PERIOD_PERIOD_PERIOD = const TokenType.con2('PERIOD_PER
IOD_PERIOD', 67, TokenClass.NO_CLASS, "..."); | 2556 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO
D_PERIOD', 67, null, "..."); |
| 2503 | 2557 |
| 2504 static const List<TokenType> values = const [ | 2558 static final List<TokenType> values = [ |
| 2505 EOF, | 2559 EOF, |
| 2506 DOUBLE, | 2560 DOUBLE, |
| 2507 HEXADECIMAL, | 2561 HEXADECIMAL, |
| 2508 IDENTIFIER, | 2562 IDENTIFIER, |
| 2509 INT, | 2563 INT, |
| 2510 KEYWORD, | 2564 KEYWORD, |
| 2511 MULTI_LINE_COMMENT, | 2565 MULTI_LINE_COMMENT, |
| 2512 SCRIPT_TAG, | 2566 SCRIPT_TAG, |
| 2513 SINGLE_LINE_COMMENT, | 2567 SINGLE_LINE_COMMENT, |
| 2514 STRING, | 2568 STRING, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2567 TILDE, | 2621 TILDE, |
| 2568 TILDE_SLASH, | 2622 TILDE_SLASH, |
| 2569 TILDE_SLASH_EQ, | 2623 TILDE_SLASH_EQ, |
| 2570 BACKPING, | 2624 BACKPING, |
| 2571 BACKSLASH, | 2625 BACKSLASH, |
| 2572 PERIOD_PERIOD_PERIOD]; | 2626 PERIOD_PERIOD_PERIOD]; |
| 2573 | 2627 |
| 2574 /** | 2628 /** |
| 2575 * The class of the token. | 2629 * The class of the token. |
| 2576 */ | 2630 */ |
| 2577 final TokenClass _tokenClass; | 2631 TokenClass _tokenClass; |
| 2578 | 2632 |
| 2579 /** | 2633 /** |
| 2580 * The lexeme that defines this type of token, or `null` if there is more than
one possible | 2634 * The lexeme that defines this type of token, or `null` if there is more than
one possible |
| 2581 * lexeme for this type of token. | 2635 * lexeme for this type of token. |
| 2582 */ | 2636 */ |
| 2583 final String lexeme; | 2637 String _lexeme; |
| 2584 | 2638 |
| 2585 const TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, Toke
nClass.NO_CLASS, null); | 2639 TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, TokenClass
.NO_CLASS, null); |
| 2586 | 2640 |
| 2587 const TokenType.con2(String name, int ordinal, this._tokenClass, this.lexeme)
: super(name, ordinal); | 2641 TokenType.con2(String name, int ordinal, TokenClass tokenClass, String lexeme)
: super(name, ordinal) { |
| 2642 this._tokenClass = tokenClass == null ? TokenClass.NO_CLASS : tokenClass; |
| 2643 this._lexeme = lexeme; |
| 2644 } |
| 2645 |
| 2646 /** |
| 2647 * Return the lexeme that defines this type of token, or `null` if there is mo
re than one |
| 2648 * possible lexeme for this type of token. |
| 2649 * |
| 2650 * @return the lexeme that defines this type of token |
| 2651 */ |
| 2652 String get lexeme => _lexeme; |
| 2588 | 2653 |
| 2589 /** | 2654 /** |
| 2590 * Return the precedence of the token, or `0` if the token does not represent
an operator. | 2655 * Return the precedence of the token, or `0` if the token does not represent
an operator. |
| 2591 * | 2656 * |
| 2592 * @return the precedence of the token | 2657 * @return the precedence of the token |
| 2593 */ | 2658 */ |
| 2594 int get precedence => _tokenClass.precedence; | 2659 int get precedence => _tokenClass.precedence; |
| 2595 | 2660 |
| 2596 /** | 2661 /** |
| 2597 * Return `true` if this type of token represents an additive operator. | 2662 * Return `true` if this type of token represents an additive operator. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2626 * | 2691 * |
| 2627 * @return `true` if this type of token represents an equality operator | 2692 * @return `true` if this type of token represents an equality operator |
| 2628 */ | 2693 */ |
| 2629 bool get isEqualityOperator => identical(_tokenClass, TokenClass.EQUALITY_OPER
ATOR); | 2694 bool get isEqualityOperator => identical(_tokenClass, TokenClass.EQUALITY_OPER
ATOR); |
| 2630 | 2695 |
| 2631 /** | 2696 /** |
| 2632 * Return `true` if this type of token represents an increment operator. | 2697 * Return `true` if this type of token represents an increment operator. |
| 2633 * | 2698 * |
| 2634 * @return `true` if this type of token represents an increment operator | 2699 * @return `true` if this type of token represents an increment operator |
| 2635 */ | 2700 */ |
| 2636 bool get isIncrementOperator => identical(lexeme, "++") || identical(lexeme, "
--"); | 2701 bool get isIncrementOperator => identical(_lexeme, "++") || identical(_lexeme,
"--"); |
| 2637 | 2702 |
| 2638 /** | 2703 /** |
| 2639 * Return `true` if this type of token represents a multiplicative operator. | 2704 * Return `true` if this type of token represents a multiplicative operator. |
| 2640 * | 2705 * |
| 2641 * @return `true` if this type of token represents a multiplicative operator | 2706 * @return `true` if this type of token represents a multiplicative operator |
| 2642 */ | 2707 */ |
| 2643 bool get isMultiplicativeOperator => identical(_tokenClass, TokenClass.MULTIPL
ICATIVE_OPERATOR); | 2708 bool get isMultiplicativeOperator => identical(_tokenClass, TokenClass.MULTIPL
ICATIVE_OPERATOR); |
| 2644 | 2709 |
| 2645 /** | 2710 /** |
| 2646 * Return `true` if this token type represents an operator. | 2711 * Return `true` if this token type represents an operator. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2675 * | 2740 * |
| 2676 * @return `true` if this type of token represents a unary prefix operator | 2741 * @return `true` if this type of token represents a unary prefix operator |
| 2677 */ | 2742 */ |
| 2678 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF
IX_OPERATOR); | 2743 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF
IX_OPERATOR); |
| 2679 | 2744 |
| 2680 /** | 2745 /** |
| 2681 * Return `true` if this token type represents an operator that can be defined
by users. | 2746 * Return `true` if this token type represents an operator that can be defined
by users. |
| 2682 * | 2747 * |
| 2683 * @return `true` if this token type represents an operator that can be define
d by users | 2748 * @return `true` if this token type represents an operator that can be define
d by users |
| 2684 */ | 2749 */ |
| 2685 bool get isUserDefinableOperator => identical(lexeme, "==") || identical(lexem
e, "~") || identical(lexeme, "[]") || identical(lexeme, "[]=") || identical(lexe
me, "*") || identical(lexeme, "/") || identical(lexeme, "%") || identical(lexeme
, "~/") || identical(lexeme, "+") || identical(lexeme, "-") || identical(lexeme,
"<<") || identical(lexeme, ">>") || identical(lexeme, ">=") || identical(lexeme
, ">") || identical(lexeme, "<=") || identical(lexeme, "<") || identical(lexeme,
"&") || identical(lexeme, "^") || identical(lexeme, "|"); | 2750 bool get isUserDefinableOperator => identical(_lexeme, "==") || identical(_lex
eme, "~") || identical(_lexeme, "[]") || identical(_lexeme, "[]=") || identical(
_lexeme, "*") || identical(_lexeme, "/") || identical(_lexeme, "%") || identical
(_lexeme, "~/") || identical(_lexeme, "+") || identical(_lexeme, "-") || identic
al(_lexeme, "<<") || identical(_lexeme, ">>") || identical(_lexeme, ">=") || ide
ntical(_lexeme, ">") || identical(_lexeme, "<=") || identical(_lexeme, "<") || i
dentical(_lexeme, "&") || identical(_lexeme, "^") || identical(_lexeme, "|"); |
| 2686 } | 2751 } |
| 2687 | 2752 |
| 2688 class TokenType_EOF extends TokenType { | 2753 class TokenType_EOF extends TokenType { |
| 2689 const TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) :
super.con2(name, ordinal, arg0, arg1); | 2754 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super.
con2(name, ordinal, arg0, arg1); |
| 2690 | 2755 |
| 2691 @override | 2756 @override |
| 2692 String toString() => "-eof-"; | 2757 String toString() => "-eof-"; |
| 2693 } | 2758 } |
| OLD | NEW |