Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: pkg/analyzer/lib/src/generated/scanner.dart

Issue 221483002: Fix for translation of \!= to \!identical(), but use == and \!= for Enum. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/generated/sdk.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 List<KeywordState> _table; 100 final 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(List<KeywordState> table, String syntax) { 115 KeywordState(this._table, String syntax) {
116 this._table = table;
117 this._keyword = (syntax == null) ? null : Keyword.keywords[syntax]; 116 this._keyword = (syntax == null) ? null : Keyword.keywords[syntax];
118 } 117 }
119 118
120 /** 119 /**
121 * Return the keyword that was recognized by this state, or `null` if this sta te does not 120 * Return the keyword that was recognized by this state, or `null` if this sta te does not
122 * recognized a keyword. 121 * recognized a keyword.
123 * 122 *
124 * @return the keyword that was matched by reaching this state 123 * @return the keyword that was matched by reaching this state
125 */ 124 */
126 Keyword keyword() => _keyword; 125 Keyword keyword() => _keyword;
127 126
128 /** 127 /**
129 * Return the state that follows this state on a transition of the given chara cter, or 128 * Return the state that follows this state on a transition of the given chara cter, or
130 * `null` if there is no valid state reachable from this state with such a tra nsition. 129 * `null` if there is no valid state reachable from this state with such a tra nsition.
131 * 130 *
132 * @param c the character used to transition from this state to another state 131 * @param c the character used to transition from this state to another state
133 * @return the state that follows this state on a transition of the given char acter 132 * @return the state that follows this state on a transition of the given char acter
134 */ 133 */
135 KeywordState next(int c) => _table[c - 0x61]; 134 KeywordState next(int c) => _table[c - 0x61];
136 } 135 }
137 136
138 /** 137 /**
139 * The enumeration `ScannerErrorCode` defines the error codes used for errors de tected by the 138 * The enumeration `ScannerErrorCode` defines the error codes used for errors de tected by the
140 * scanner. 139 * scanner.
141 */ 140 */
142 class ScannerErrorCode extends Enum<ScannerErrorCode> implements ErrorCode { 141 class ScannerErrorCode extends Enum<ScannerErrorCode> implements ErrorCode {
143 static final ScannerErrorCode ILLEGAL_CHARACTER = new ScannerErrorCode.con1('I LLEGAL_CHARACTER', 0, "Illegal character %x"); 142 static const ScannerErrorCode ILLEGAL_CHARACTER = const ScannerErrorCode.con1( 'ILLEGAL_CHARACTER', 0, "Illegal character %x");
144 143
145 static final ScannerErrorCode MISSING_DIGIT = new ScannerErrorCode.con1('MISSI NG_DIGIT', 1, "Decimal digit expected"); 144 static const ScannerErrorCode MISSING_DIGIT = const ScannerErrorCode.con1('MIS SING_DIGIT', 1, "Decimal digit expected");
146 145
147 static final ScannerErrorCode MISSING_HEX_DIGIT = new ScannerErrorCode.con1('M ISSING_HEX_DIGIT', 2, "Hexidecimal digit expected"); 146 static const ScannerErrorCode MISSING_HEX_DIGIT = const ScannerErrorCode.con1( 'MISSING_HEX_DIGIT', 2, "Hexidecimal digit expected");
148 147
149 static final ScannerErrorCode MISSING_QUOTE = new ScannerErrorCode.con1('MISSI NG_QUOTE', 3, "Expected quote (' or \")"); 148 static const ScannerErrorCode MISSING_QUOTE = const ScannerErrorCode.con1('MIS SING_QUOTE', 3, "Expected quote (' or \")");
150 149
151 static final ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = new ScannerErr orCode.con1('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line comme nt"); 150 static const ScannerErrorCode UNTERMINATED_MULTI_LINE_COMMENT = const ScannerE rrorCode.con1('UNTERMINATED_MULTI_LINE_COMMENT', 4, "Unterminated multi-line com ment");
152 151
153 static final ScannerErrorCode UNTERMINATED_STRING_LITERAL = new ScannerErrorCo de.con1('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal"); 152 static const ScannerErrorCode UNTERMINATED_STRING_LITERAL = const ScannerError Code.con1('UNTERMINATED_STRING_LITERAL', 5, "Unterminated string literal");
154 153
155 static final List<ScannerErrorCode> values = [ 154 static const List<ScannerErrorCode> values = const [
156 ILLEGAL_CHARACTER, 155 ILLEGAL_CHARACTER,
157 MISSING_DIGIT, 156 MISSING_DIGIT,
158 MISSING_HEX_DIGIT, 157 MISSING_HEX_DIGIT,
159 MISSING_QUOTE, 158 MISSING_QUOTE,
160 UNTERMINATED_MULTI_LINE_COMMENT, 159 UNTERMINATED_MULTI_LINE_COMMENT,
161 UNTERMINATED_STRING_LITERAL]; 160 UNTERMINATED_STRING_LITERAL];
162 161
163 /** 162 /**
164 * The template used to create the message to be displayed for this error. 163 * The template used to create the message to be displayed for this error.
165 */ 164 */
166 String message; 165 final String message;
167 166
168 /** 167 /**
169 * The template used to create the correction to be displayed for this error, or `null` if 168 * The template used to create the correction to be displayed for this error, or `null` if
170 * there is no correction information for this error. 169 * there is no correction information for this error.
171 */ 170 */
172 String correction10; 171 final String correction;
173 172
174 /** 173 /**
175 * Initialize a newly created error code to have the given message. 174 * Initialize a newly created error code to have the given message.
176 * 175 *
177 * @param message the message template used to create the message to be displa yed for this error 176 * @param message the message template used to create the message to be displa yed for this error
178 */ 177 */
179 ScannerErrorCode.con1(String name, int ordinal, String message) : super(name, ordinal) { 178 const ScannerErrorCode.con1(String name, int ordinal, String message) : this.c on2(name, ordinal, message, null);
180 this.message = message;
181 }
182 179
183 /** 180 /**
184 * Initialize a newly created error code to have the given message and correct ion. 181 * Initialize a newly created error code to have the given message and correct ion.
185 * 182 *
186 * @param message the template used to create the message to be displayed for the error 183 * @param message the template used to create the message to be displayed for the error
187 * @param correction the template used to create the correction to be displaye d for the error 184 * @param correction the template used to create the correction to be displaye d for the error
188 */ 185 */
189 ScannerErrorCode.con2(String name, int ordinal, String message, String correct ion) : super(name, ordinal) { 186 const ScannerErrorCode.con2(String name, int ordinal, this.message, this.corre ction) : super(name, ordinal);
190 this.message = message;
191 this.correction10 = correction;
192 }
193
194 @override
195 String get correction => correction10;
196 187
197 @override 188 @override
198 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; 189 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
199 190
200 @override 191 @override
201 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 192 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
202 } 193 }
203 194
204 /** 195 /**
205 * Instances of the class `SubSequenceReader` implement a [CharacterReader] that reads 196 * Instances of the class `SubSequenceReader` implement a [CharacterReader] that reads
206 * characters from a character sequence, but adds a delta when reporting the cur rent character 197 * characters from a character sequence, but adds a delta when reporting the cur rent character
207 * offset so that the character sequence can be a subsequence from a larger sequ ence. 198 * offset so that the character sequence can be a subsequence from a larger sequ ence.
208 */ 199 */
209 class SubSequenceReader extends CharSequenceReader { 200 class SubSequenceReader extends CharSequenceReader {
210 /** 201 /**
211 * The offset from the beginning of the file to the beginning of the source be ing scanned. 202 * The offset from the beginning of the file to the beginning of the source be ing scanned.
212 */ 203 */
213 int _offsetDelta = 0; 204 final int _offsetDelta;
214 205
215 /** 206 /**
216 * Initialize a newly created reader to read the characters in the given seque nce. 207 * Initialize a newly created reader to read the characters in the given seque nce.
217 * 208 *
218 * @param sequence the sequence from which characters will be read 209 * @param sequence the sequence from which characters will be read
219 * @param offsetDelta the offset from the beginning of the file to the beginni ng of the source 210 * @param offsetDelta the offset from the beginning of the file to the beginni ng of the source
220 * being scanned 211 * being scanned
221 */ 212 */
222 SubSequenceReader(String sequence, int offsetDelta) : super(sequence) { 213 SubSequenceReader(String sequence, this._offsetDelta) : super(sequence);
223 this._offsetDelta = offsetDelta;
224 }
225 214
226 @override 215 @override
227 int get offset => _offsetDelta + super.offset; 216 int get offset => _offsetDelta + super.offset;
228 217
229 @override 218 @override
230 String getString(int start, int endDelta) => super.getString(start - _offsetDe lta, endDelta); 219 String getString(int start, int endDelta) => super.getString(start - _offsetDe lta, endDelta);
231 220
232 @override 221 @override
233 void set offset(int offset) { 222 void set offset(int offset) {
234 super.offset = offset - _offsetDelta; 223 super.offset = offset - _offsetDelta;
235 } 224 }
236 } 225 }
237 226
238 /** 227 /**
239 * Instances of the class `TokenWithComment` represent a string token that is pr eceded by 228 * Instances of the class `TokenWithComment` represent a string token that is pr eceded by
240 * comments. 229 * comments.
241 */ 230 */
242 class StringTokenWithComment extends StringToken { 231 class StringTokenWithComment extends StringToken {
243 /** 232 /**
244 * The first comment in the list of comments that precede this token. 233 * The first comment in the list of comments that precede this token.
245 */ 234 */
246 Token _precedingComment; 235 final Token _precedingComment;
247 236
248 /** 237 /**
249 * Initialize a newly created token to have the given type and offset and to b e preceded by the 238 * Initialize a newly created token to have the given type and offset and to b e preceded by the
250 * comments reachable from the given comment. 239 * comments reachable from the given comment.
251 * 240 *
252 * @param type the type of the token 241 * @param type the type of the token
253 * @param offset the offset from the beginning of the file to the first charac ter in the token 242 * @param offset the offset from the beginning of the file to the first charac ter in the token
254 * @param precedingComment the first comment in the list of comments that prec ede this token 243 * @param precedingComment the first comment in the list of comments that prec ede this token
255 */ 244 */
256 StringTokenWithComment(TokenType type, String value, int offset, Token precedi ngComment) : super(type, value, offset) { 245 StringTokenWithComment(TokenType type, String value, int offset, this._precedi ngComment) : super(type, value, offset);
257 this._precedingComment = precedingComment;
258 }
259 246
260 @override 247 @override
261 Token copy() => new StringTokenWithComment(type, lexeme, offset, copyComments( _precedingComment)); 248 Token copy() => new StringTokenWithComment(type, lexeme, offset, copyComments( _precedingComment));
262 249
263 @override 250 @override
264 Token get precedingComments => _precedingComment; 251 Token get precedingComments => _precedingComment;
265 252
266 @override 253 @override
267 void applyDelta(int delta) { 254 void applyDelta(int delta) {
268 super.applyDelta(delta); 255 super.applyDelta(delta);
269 Token token = _precedingComment; 256 Token token = _precedingComment;
270 while (token != null) { 257 while (token != null) {
271 token.applyDelta(delta); 258 token.applyDelta(delta);
272 token = token.next; 259 token = token.next;
273 } 260 }
274 } 261 }
275 } 262 }
276 263
277 /** 264 /**
278 * The enumeration `Keyword` defines the keywords in the Dart programming langua ge. 265 * The enumeration `Keyword` defines the keywords in the Dart programming langua ge.
279 */ 266 */
280 class Keyword extends Enum<Keyword> { 267 class Keyword extends Enum<Keyword> {
281 static final Keyword ASSERT = new Keyword.con1('ASSERT', 0, "assert"); 268 static const Keyword ASSERT = const Keyword.con1('ASSERT', 0, "assert");
282 269
283 static final Keyword BREAK = new Keyword.con1('BREAK', 1, "break"); 270 static const Keyword BREAK = const Keyword.con1('BREAK', 1, "break");
284 271
285 static final Keyword CASE = new Keyword.con1('CASE', 2, "case"); 272 static const Keyword CASE = const Keyword.con1('CASE', 2, "case");
286 273
287 static final Keyword CATCH = new Keyword.con1('CATCH', 3, "catch"); 274 static const Keyword CATCH = const Keyword.con1('CATCH', 3, "catch");
288 275
289 static final Keyword CLASS = new Keyword.con1('CLASS', 4, "class"); 276 static const Keyword CLASS = const Keyword.con1('CLASS', 4, "class");
290 277
291 static final Keyword CONST = new Keyword.con1('CONST', 5, "const"); 278 static const Keyword CONST = const Keyword.con1('CONST', 5, "const");
292 279
293 static final Keyword CONTINUE = new Keyword.con1('CONTINUE', 6, "continue"); 280 static const Keyword CONTINUE = const Keyword.con1('CONTINUE', 6, "continue");
294 281
295 static final Keyword DEFAULT = new Keyword.con1('DEFAULT', 7, "default"); 282 static const Keyword DEFAULT = const Keyword.con1('DEFAULT', 7, "default");
296 283
297 static final Keyword DO = new Keyword.con1('DO', 8, "do"); 284 static const Keyword DO = const Keyword.con1('DO', 8, "do");
298 285
299 static final Keyword ELSE = new Keyword.con1('ELSE', 9, "else"); 286 static const Keyword ELSE = const Keyword.con1('ELSE', 9, "else");
300 287
301 static final Keyword ENUM = new Keyword.con1('ENUM', 10, "enum"); 288 static const Keyword ENUM = const Keyword.con1('ENUM', 10, "enum");
302 289
303 static final Keyword EXTENDS = new Keyword.con1('EXTENDS', 11, "extends"); 290 static const Keyword EXTENDS = const Keyword.con1('EXTENDS', 11, "extends");
304 291
305 static final Keyword FALSE = new Keyword.con1('FALSE', 12, "false"); 292 static const Keyword FALSE = const Keyword.con1('FALSE', 12, "false");
306 293
307 static final Keyword FINAL = new Keyword.con1('FINAL', 13, "final"); 294 static const Keyword FINAL = const Keyword.con1('FINAL', 13, "final");
308 295
309 static final Keyword FINALLY = new Keyword.con1('FINALLY', 14, "finally"); 296 static const Keyword FINALLY = const Keyword.con1('FINALLY', 14, "finally");
310 297
311 static final Keyword FOR = new Keyword.con1('FOR', 15, "for"); 298 static const Keyword FOR = const Keyword.con1('FOR', 15, "for");
312 299
313 static final Keyword IF = new Keyword.con1('IF', 16, "if"); 300 static const Keyword IF = const Keyword.con1('IF', 16, "if");
314 301
315 static final Keyword IN = new Keyword.con1('IN', 17, "in"); 302 static const Keyword IN = const Keyword.con1('IN', 17, "in");
316 303
317 static final Keyword IS = new Keyword.con1('IS', 18, "is"); 304 static const Keyword IS = const Keyword.con1('IS', 18, "is");
318 305
319 static final Keyword NEW = new Keyword.con1('NEW', 19, "new"); 306 static const Keyword NEW = const Keyword.con1('NEW', 19, "new");
320 307
321 static final Keyword NULL = new Keyword.con1('NULL', 20, "null"); 308 static const Keyword NULL = const Keyword.con1('NULL', 20, "null");
322 309
323 static final Keyword RETHROW = new Keyword.con1('RETHROW', 21, "rethrow"); 310 static const Keyword RETHROW = const Keyword.con1('RETHROW', 21, "rethrow");
324 311
325 static final Keyword RETURN = new Keyword.con1('RETURN', 22, "return"); 312 static const Keyword RETURN = const Keyword.con1('RETURN', 22, "return");
326 313
327 static final Keyword SUPER = new Keyword.con1('SUPER', 23, "super"); 314 static const Keyword SUPER = const Keyword.con1('SUPER', 23, "super");
328 315
329 static final Keyword SWITCH = new Keyword.con1('SWITCH', 24, "switch"); 316 static const Keyword SWITCH = const Keyword.con1('SWITCH', 24, "switch");
330 317
331 static final Keyword THIS = new Keyword.con1('THIS', 25, "this"); 318 static const Keyword THIS = const Keyword.con1('THIS', 25, "this");
332 319
333 static final Keyword THROW = new Keyword.con1('THROW', 26, "throw"); 320 static const Keyword THROW = const Keyword.con1('THROW', 26, "throw");
334 321
335 static final Keyword TRUE = new Keyword.con1('TRUE', 27, "true"); 322 static const Keyword TRUE = const Keyword.con1('TRUE', 27, "true");
336 323
337 static final Keyword TRY = new Keyword.con1('TRY', 28, "try"); 324 static const Keyword TRY = const Keyword.con1('TRY', 28, "try");
338 325
339 static final Keyword VAR = new Keyword.con1('VAR', 29, "var"); 326 static const Keyword VAR = const Keyword.con1('VAR', 29, "var");
340 327
341 static final Keyword VOID = new Keyword.con1('VOID', 30, "void"); 328 static const Keyword VOID = const Keyword.con1('VOID', 30, "void");
342 329
343 static final Keyword WHILE = new Keyword.con1('WHILE', 31, "while"); 330 static const Keyword WHILE = const Keyword.con1('WHILE', 31, "while");
344 331
345 static final Keyword WITH = new Keyword.con1('WITH', 32, "with"); 332 static const Keyword WITH = const Keyword.con1('WITH', 32, "with");
346 333
347 static final Keyword ABSTRACT = new Keyword.con2('ABSTRACT', 33, "abstract", t rue); 334 static const Keyword ABSTRACT = const Keyword.con2('ABSTRACT', 33, "abstract", true);
348 335
349 static final Keyword AS = new Keyword.con2('AS', 34, "as", true); 336 static const Keyword AS = const Keyword.con2('AS', 34, "as", true);
350 337
351 static final Keyword DYNAMIC = new Keyword.con2('DYNAMIC', 35, "dynamic", true ); 338 static const Keyword DYNAMIC = const Keyword.con2('DYNAMIC', 35, "dynamic", tr ue);
352 339
353 static final Keyword EXPORT = new Keyword.con2('EXPORT', 36, "export", true); 340 static const Keyword EXPORT = const Keyword.con2('EXPORT', 36, "export", true) ;
354 341
355 static final Keyword EXTERNAL = new Keyword.con2('EXTERNAL', 37, "external", t rue); 342 static const Keyword EXTERNAL = const Keyword.con2('EXTERNAL', 37, "external", true);
356 343
357 static final Keyword FACTORY = new Keyword.con2('FACTORY', 38, "factory", true ); 344 static const Keyword FACTORY = const Keyword.con2('FACTORY', 38, "factory", tr ue);
358 345
359 static final Keyword GET = new Keyword.con2('GET', 39, "get", true); 346 static const Keyword GET = const Keyword.con2('GET', 39, "get", true);
360 347
361 static final Keyword IMPLEMENTS = new Keyword.con2('IMPLEMENTS', 40, "implemen ts", true); 348 static const Keyword IMPLEMENTS = const Keyword.con2('IMPLEMENTS', 40, "implem ents", true);
362 349
363 static final Keyword IMPORT = new Keyword.con2('IMPORT', 41, "import", true); 350 static const Keyword IMPORT = const Keyword.con2('IMPORT', 41, "import", true) ;
364 351
365 static final Keyword LIBRARY = new Keyword.con2('LIBRARY', 42, "library", true ); 352 static const Keyword LIBRARY = const Keyword.con2('LIBRARY', 42, "library", tr ue);
366 353
367 static final Keyword OPERATOR = new Keyword.con2('OPERATOR', 43, "operator", t rue); 354 static const Keyword OPERATOR = const Keyword.con2('OPERATOR', 43, "operator", true);
368 355
369 static final Keyword PART = new Keyword.con2('PART', 44, "part", true); 356 static const Keyword PART = const Keyword.con2('PART', 44, "part", true);
370 357
371 static final Keyword SET = new Keyword.con2('SET', 45, "set", true); 358 static const Keyword SET = const Keyword.con2('SET', 45, "set", true);
372 359
373 static final Keyword STATIC = new Keyword.con2('STATIC', 46, "static", true); 360 static const Keyword STATIC = const Keyword.con2('STATIC', 46, "static", true) ;
374 361
375 static final Keyword TYPEDEF = new Keyword.con2('TYPEDEF', 47, "typedef", true ); 362 static const Keyword TYPEDEF = const Keyword.con2('TYPEDEF', 47, "typedef", tr ue);
376 363
377 static final List<Keyword> values = [ 364 static const List<Keyword> values = const [
378 ASSERT, 365 ASSERT,
379 BREAK, 366 BREAK,
380 CASE, 367 CASE,
381 CATCH, 368 CATCH,
382 CLASS, 369 CLASS,
383 CONST, 370 CONST,
384 CONTINUE, 371 CONTINUE,
385 DEFAULT, 372 DEFAULT,
386 DO, 373 DO,
387 ELSE, 374 ELSE,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 LIBRARY, 407 LIBRARY,
421 OPERATOR, 408 OPERATOR,
422 PART, 409 PART,
423 SET, 410 SET,
424 STATIC, 411 STATIC,
425 TYPEDEF]; 412 TYPEDEF];
426 413
427 /** 414 /**
428 * The lexeme for the keyword. 415 * The lexeme for the keyword.
429 */ 416 */
430 String _syntax; 417 final String syntax;
431 418
432 /** 419 /**
433 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords can be used as 420 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords can be used as
434 * identifiers. 421 * identifiers.
435 */ 422 */
436 bool _isPseudoKeyword = false; 423 final bool isPseudoKeyword;
437 424
438 /** 425 /**
439 * A table mapping the lexemes of keywords to the corresponding keyword. 426 * A table mapping the lexemes of keywords to the corresponding keyword.
440 */ 427 */
441 static Map<String, Keyword> keywords = _createKeywordMap(); 428 static Map<String, Keyword> keywords = _createKeywordMap();
442 429
443 /** 430 /**
444 * Create a table mapping the lexemes of keywords to the corresponding keyword . 431 * Create a table mapping the lexemes of keywords to the corresponding keyword .
445 * 432 *
446 * @return the table that was created 433 * @return the table that was created
447 */ 434 */
448 static Map<String, Keyword> _createKeywordMap() { 435 static Map<String, Keyword> _createKeywordMap() {
449 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ; 436 LinkedHashMap<String, Keyword> result = new LinkedHashMap<String, Keyword>() ;
450 for (Keyword keyword in values) { 437 for (Keyword keyword in values) {
451 result[keyword._syntax] = keyword; 438 result[keyword.syntax] = keyword;
452 } 439 }
453 return result; 440 return result;
454 } 441 }
455 442
456 /** 443 /**
457 * Initialize a newly created keyword to have the given syntax. The keyword is not a 444 * Initialize a newly created keyword to have the given syntax. The keyword is not a
458 * pseudo-keyword. 445 * pseudo-keyword.
459 * 446 *
460 * @param syntax the lexeme for the keyword 447 * @param syntax the lexeme for the keyword
461 */ 448 */
462 Keyword.con1(String name, int ordinal, String syntax) : this.con2(name, ordina l, syntax, false); 449 const Keyword.con1(String name, int ordinal, String syntax) : this.con2(name, ordinal, syntax, false);
463 450
464 /** 451 /**
465 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if 452 * Initialize a newly created keyword to have the given syntax. The keyword is a pseudo-keyword if
466 * the given flag is `true`. 453 * the given flag is `true`.
467 * 454 *
468 * @param syntax the lexeme for the keyword 455 * @param syntax the lexeme for the keyword
469 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword 456 * @param isPseudoKeyword `true` if this keyword is a pseudo-keyword
470 */ 457 */
471 Keyword.con2(String name, int ordinal, String syntax, bool isPseudoKeyword) : super(name, ordinal) { 458 const Keyword.con2(String name, int ordinal, this.syntax, this.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;
490 } 459 }
491 460
492 /** 461 /**
493 * Instances of the class `CharSequenceReader` implement a [CharacterReader] tha t reads 462 * Instances of the class `CharSequenceReader` implement a [CharacterReader] tha t reads
494 * characters from a character sequence. 463 * characters from a character sequence.
495 */ 464 */
496 class CharSequenceReader implements CharacterReader { 465 class CharSequenceReader implements CharacterReader {
497 /** 466 /**
498 * The sequence from which characters will be read. 467 * The sequence from which characters will be read.
499 */ 468 */
500 String _sequence; 469 final String _sequence;
501 470
502 /** 471 /**
503 * The number of characters in the string. 472 * The number of characters in the string.
504 */ 473 */
505 int _stringLength = 0; 474 int _stringLength = 0;
506 475
507 /** 476 /**
508 * The index, relative to the string, of the last character that was read. 477 * The index, relative to the string, of the last character that was read.
509 */ 478 */
510 int _charOffset = 0; 479 int _charOffset = 0;
511 480
512 /** 481 /**
513 * Initialize a newly created reader to read the characters in the given seque nce. 482 * Initialize a newly created reader to read the characters in the given seque nce.
514 * 483 *
515 * @param sequence the sequence from which characters will be read 484 * @param sequence the sequence from which characters will be read
516 */ 485 */
517 CharSequenceReader(String sequence) { 486 CharSequenceReader(this._sequence) {
518 this._sequence = sequence; 487 this._stringLength = _sequence.length;
519 this._stringLength = sequence.length;
520 this._charOffset = -1; 488 this._charOffset = -1;
521 } 489 }
522 490
523 @override 491 @override
524 int advance() { 492 int advance() {
525 if (_charOffset + 1 >= _stringLength) { 493 if (_charOffset + 1 >= _stringLength) {
526 return -1; 494 return -1;
527 } 495 }
528 return _sequence.codeUnitAt(++_charOffset); 496 return _sequence.codeUnitAt(++_charOffset);
529 } 497 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 // as in "ab" --> "a.b". 675 // as in "ab" --> "a.b".
708 // 676 //
709 _reader.offset = scanStart - 1; 677 _reader.offset = scanStart - 1;
710 int next = _reader.advance(); 678 int next = _reader.advance();
711 while (next != -1 && _reader.offset <= scanEnd) { 679 while (next != -1 && _reader.offset <= scanEnd) {
712 next = bigSwitch(next); 680 next = bigSwitch(next);
713 } 681 }
714 // 682 //
715 // Copy the remaining tokens in the original stream, but apply the delta to the token's offset. 683 // Copy the remaining tokens in the original stream, but apply the delta to the token's offset.
716 // 684 //
717 if (identical(originalStream.type, TokenType.EOF)) { 685 if (originalStream.type == TokenType.EOF) {
718 _copyAndAdvance(originalStream, delta); 686 _copyAndAdvance(originalStream, delta);
719 _rightToken = tail; 687 _rightToken = tail;
720 _rightToken.setNextWithoutSettingPrevious(_rightToken); 688 _rightToken.setNextWithoutSettingPrevious(_rightToken);
721 } else { 689 } else {
722 originalStream = _copyAndAdvance(originalStream, delta); 690 originalStream = _copyAndAdvance(originalStream, delta);
723 _rightToken = tail; 691 _rightToken = tail;
724 while (originalStream.type != TokenType.EOF) { 692 while (originalStream.type != TokenType.EOF) {
725 originalStream = _copyAndAdvance(originalStream, delta); 693 originalStream = _copyAndAdvance(originalStream, delta);
726 } 694 }
727 Token eof = _copyAndAdvance(originalStream, delta); 695 Token eof = _copyAndAdvance(originalStream, delta);
728 eof.setNextWithoutSettingPrevious(eof); 696 eof.setNextWithoutSettingPrevious(eof);
729 } 697 }
730 // 698 //
731 // If the index is immediately after an existing token and the inserted char acters did not 699 // If the index is immediately after an existing token and the inserted char acters did not
732 // change that original token, then adjust the leftToken to be the next toke n. For example, in 700 // change that original token, then adjust the leftToken to be the next toke n. For example, in
733 // "a; c;" --> "a;b c;", the leftToken was ";", but this code advances it to "b" since "b" is 701 // "a; c;" --> "a;b c;", the leftToken was ";", but this code advances it to "b" since "b" is
734 // the first new token. 702 // the first new token.
735 // 703 //
736 Token newFirst = _leftToken.next; 704 Token newFirst = _leftToken.next;
737 while (newFirst != _rightToken && oldFirst != oldRightToken && newFirst.type != TokenType.EOF && _equalTokens(oldFirst, newFirst)) { 705 while (!identical(newFirst, _rightToken) && !identical(oldFirst, oldRightTok en) && newFirst.type != TokenType.EOF && _equalTokens(oldFirst, newFirst)) {
738 _tokenMap.put(oldFirst, newFirst); 706 _tokenMap.put(oldFirst, newFirst);
739 oldLeftToken = oldFirst; 707 oldLeftToken = oldFirst;
740 oldFirst = oldFirst.next; 708 oldFirst = oldFirst.next;
741 _leftToken = newFirst; 709 _leftToken = newFirst;
742 newFirst = newFirst.next; 710 newFirst = newFirst.next;
743 } 711 }
744 Token newLast = _rightToken.previous; 712 Token newLast = _rightToken.previous;
745 while (newLast != _leftToken && oldLast != oldLeftToken && newLast.type != T okenType.EOF && _equalTokens(oldLast, newLast)) { 713 while (!identical(newLast, _leftToken) && !identical(oldLast, oldLeftToken) && newLast.type != TokenType.EOF && _equalTokens(oldLast, newLast)) {
746 _tokenMap.put(oldLast, newLast); 714 _tokenMap.put(oldLast, newLast);
747 oldRightToken = oldLast; 715 oldRightToken = oldLast;
748 oldLast = oldLast.previous; 716 oldLast = oldLast.previous;
749 _rightToken = newLast; 717 _rightToken = newLast;
750 newLast = newLast.previous; 718 newLast = newLast.previous;
751 } 719 }
752 _hasNonWhitespaceChange = _leftToken.next != _rightToken || oldLeftToken.nex t != oldRightToken; 720 _hasNonWhitespaceChange = !identical(_leftToken.next, _rightToken) || !ident ical(oldLeftToken.next, oldRightToken);
753 // 721 //
754 // TODO(brianwilkerson) Begin tokens are not getting associated with the cor responding end 722 // TODO(brianwilkerson) Begin tokens are not getting associated with the cor responding end
755 // tokens (because the end tokens have not been copied when we're copyin g the begin tokens). 723 // tokens (because the end tokens have not been copied when we're copyin g the begin tokens).
756 // This could have implications for parsing. 724 // This could have implications for parsing.
757 // TODO(brianwilkerson) Update the lineInfo. 725 // TODO(brianwilkerson) Update the lineInfo.
758 // 726 //
759 return firstToken; 727 return firstToken;
760 } 728 }
761 729
762 Token _copyAndAdvance(Token originalToken, int delta) { 730 Token _copyAndAdvance(Token originalToken, int delta) {
(...skipping 12 matching lines...) Expand all
775 } 743 }
776 744
777 /** 745 /**
778 * Return `true` if the two tokens are equal to each other. For the purposes o f the 746 * Return `true` if the two tokens are equal to each other. For the purposes o f the
779 * incremental scanner, two tokens are equal if they have the same type and le xeme. 747 * incremental scanner, two tokens are equal if they have the same type and le xeme.
780 * 748 *
781 * @param oldToken the token from the old stream that is being compared 749 * @param oldToken the token from the old stream that is being compared
782 * @param newToken the token from the new stream that is being compared 750 * @param newToken the token from the new stream that is being compared
783 * @return `true` if the two tokens are equal to each other 751 * @return `true` if the two tokens are equal to each other
784 */ 752 */
785 bool _equalTokens(Token oldToken, Token newToken) => identical(oldToken.type, newToken.type) && oldToken.length == newToken.length && oldToken.lexeme == newTo ken.lexeme; 753 bool _equalTokens(Token oldToken, Token newToken) => oldToken.type == newToken .type && oldToken.length == newToken.length && oldToken.lexeme == newToken.lexem e;
786 } 754 }
787 755
788 /** 756 /**
789 * The class `Scanner` implements a scanner for Dart code. 757 * The class `Scanner` implements a scanner for Dart code.
790 * 758 *
791 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is 759 * The lexical structure of Dart is ambiguous without knowledge of the context i n which a token is
792 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<" 760 * being scanned. For example, without context we cannot determine whether sourc e of the form "<<"
793 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner 761 * should be scanned as a single left-shift operator or as two left angle bracke ts. This scanner
794 * does not have any context, so it always resolves such conflicts by scanning t he longest possible 762 * does not have any context, so it always resolves such conflicts by scanning t he longest possible
795 * token. 763 * token.
796 */ 764 */
797 class Scanner { 765 class Scanner {
798 /** 766 /**
799 * The source being scanned. 767 * The source being scanned.
800 */ 768 */
801 Source source; 769 final Source source;
802 770
803 /** 771 /**
804 * The reader used to access the characters in the source. 772 * The reader used to access the characters in the source.
805 */ 773 */
806 CharacterReader _reader; 774 final CharacterReader _reader;
807 775
808 /** 776 /**
809 * The error listener that will be informed of any errors that are found durin g the scan. 777 * The error listener that will be informed of any errors that are found durin g the scan.
810 */ 778 */
811 AnalysisErrorListener _errorListener; 779 final AnalysisErrorListener _errorListener;
812 780
813 /** 781 /**
814 * The flag specifying if documentation comments should be parsed. 782 * The flag specifying if documentation comments should be parsed.
815 */ 783 */
816 bool _preserveComments = true; 784 bool _preserveComments = true;
817 785
818 /** 786 /**
819 * The token pointing to the head of the linked list of tokens. 787 * The token pointing to the head of the linked list of tokens.
820 */ 788 */
821 Token _tokens; 789 Token _tokens;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 */ 829 */
862 bool _hasUnmatchedGroups = false; 830 bool _hasUnmatchedGroups = false;
863 831
864 /** 832 /**
865 * Initialize a newly created scanner. 833 * Initialize a newly created scanner.
866 * 834 *
867 * @param source the source being scanned 835 * @param source the source being scanned
868 * @param reader the character reader used to read the characters in the sourc e 836 * @param reader the character reader used to read the characters in the sourc e
869 * @param errorListener the error listener that will be informed of any errors that are found 837 * @param errorListener the error listener that will be informed of any errors that are found
870 */ 838 */
871 Scanner(Source source, CharacterReader reader, AnalysisErrorListener errorList ener) { 839 Scanner(this.source, this._reader, this._errorListener) {
872 this.source = source;
873 this._reader = reader;
874 this._errorListener = errorListener;
875 _tokens = new Token(TokenType.EOF, -1); 840 _tokens = new Token(TokenType.EOF, -1);
876 _tokens.setNext(_tokens); 841 _tokens.setNext(_tokens);
877 _tail = _tokens; 842 _tail = _tokens;
878 _tokenStart = -1; 843 _tokenStart = -1;
879 _lineStarts.add(0); 844 _lineStarts.add(0);
880 } 845 }
881 846
882 /** 847 /**
883 * Return an array containing the offsets of the first character of each line in the source code. 848 * Return an array containing the offsets of the first character of each line in the source code.
884 * 849 *
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 if (_firstComment == null) { 1117 if (_firstComment == null) {
1153 token = new Token(type, _tokenStart); 1118 token = new Token(type, _tokenStart);
1154 } else { 1119 } else {
1155 token = new TokenWithComment(type, _tokenStart, _firstComment); 1120 token = new TokenWithComment(type, _tokenStart, _firstComment);
1156 _firstComment = null; 1121 _firstComment = null;
1157 _lastComment = null; 1122 _lastComment = null;
1158 } 1123 }
1159 _tail = _tail.setNext(token); 1124 _tail = _tail.setNext(token);
1160 if (_stackEnd >= 0) { 1125 if (_stackEnd >= 0) {
1161 BeginToken begin = _groupingStack[_stackEnd]; 1126 BeginToken begin = _groupingStack[_stackEnd];
1162 if (identical(begin.type, beginType)) { 1127 if (begin.type == beginType) {
1163 begin.endToken = token; 1128 begin.endToken = token;
1164 _groupingStack.removeAt(_stackEnd--); 1129 _groupingStack.removeAt(_stackEnd--);
1165 } 1130 }
1166 } 1131 }
1167 } 1132 }
1168 1133
1169 void _appendEofToken() { 1134 void _appendEofToken() {
1170 Token eofToken; 1135 Token eofToken;
1171 if (_firstComment == null) { 1136 if (_firstComment == null) {
1172 eofToken = new Token(TokenType.EOF, _reader.offset + 1); 1137 eofToken = new Token(TokenType.EOF, _reader.offset + 1);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 /** 1205 /**
1241 * Return the beginning token corresponding to a closing brace that was found while scanning 1206 * Return the beginning token corresponding to a closing brace that was found while scanning
1242 * inside a string interpolation expression. Tokens that cannot be matched wit h the closing brace 1207 * inside a string interpolation expression. Tokens that cannot be matched wit h the closing brace
1243 * will be dropped from the stack. 1208 * will be dropped from the stack.
1244 * 1209 *
1245 * @return the token to be paired with the closing brace 1210 * @return the token to be paired with the closing brace
1246 */ 1211 */
1247 BeginToken _findTokenMatchingClosingBraceInInterpolationExpression() { 1212 BeginToken _findTokenMatchingClosingBraceInInterpolationExpression() {
1248 while (_stackEnd >= 0) { 1213 while (_stackEnd >= 0) {
1249 BeginToken begin = _groupingStack[_stackEnd]; 1214 BeginToken begin = _groupingStack[_stackEnd];
1250 if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET) || identical(begin .type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { 1215 if (begin.type == TokenType.OPEN_CURLY_BRACKET || begin.type == TokenType. STRING_INTERPOLATION_EXPRESSION) {
1251 return begin; 1216 return begin;
1252 } 1217 }
1253 _hasUnmatchedGroups = true; 1218 _hasUnmatchedGroups = true;
1254 _groupingStack.removeAt(_stackEnd--); 1219 _groupingStack.removeAt(_stackEnd--);
1255 } 1220 }
1256 // 1221 //
1257 // We should never get to this point because we wouldn't be inside a string interpolation 1222 // We should never get to this point because we wouldn't be inside a string interpolation
1258 // expression unless we had previously found the start of the expression. 1223 // expression unless we had previously found the start of the expression.
1259 // 1224 //
1260 return null; 1225 return null;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 next = _reader.advance(); 1434 next = _reader.advance();
1470 while (next != -1) { 1435 while (next != -1) {
1471 if (next == 0x7D) { 1436 if (next == 0x7D) {
1472 BeginToken begin = _findTokenMatchingClosingBraceInInterpolationExpressi on(); 1437 BeginToken begin = _findTokenMatchingClosingBraceInInterpolationExpressi on();
1473 if (begin == null) { 1438 if (begin == null) {
1474 _beginToken(); 1439 _beginToken();
1475 _appendTokenOfType(TokenType.CLOSE_CURLY_BRACKET); 1440 _appendTokenOfType(TokenType.CLOSE_CURLY_BRACKET);
1476 next = _reader.advance(); 1441 next = _reader.advance();
1477 _beginToken(); 1442 _beginToken();
1478 return next; 1443 return next;
1479 } else if (identical(begin.type, TokenType.OPEN_CURLY_BRACKET)) { 1444 } else if (begin.type == TokenType.OPEN_CURLY_BRACKET) {
1480 _beginToken(); 1445 _beginToken();
1481 _appendEndToken(TokenType.CLOSE_CURLY_BRACKET, TokenType.OPEN_CURLY_BR ACKET); 1446 _appendEndToken(TokenType.CLOSE_CURLY_BRACKET, TokenType.OPEN_CURLY_BR ACKET);
1482 next = _reader.advance(); 1447 next = _reader.advance();
1483 _beginToken(); 1448 _beginToken();
1484 } else if (identical(begin.type, TokenType.STRING_INTERPOLATION_EXPRESSI ON)) { 1449 } else if (begin.type == TokenType.STRING_INTERPOLATION_EXPRESSION) {
1485 _beginToken(); 1450 _beginToken();
1486 _appendEndToken(TokenType.CLOSE_CURLY_BRACKET, TokenType.STRING_INTERP OLATION_EXPRESSION); 1451 _appendEndToken(TokenType.CLOSE_CURLY_BRACKET, TokenType.STRING_INTERP OLATION_EXPRESSION);
1487 next = _reader.advance(); 1452 next = _reader.advance();
1488 _beginToken(); 1453 _beginToken();
1489 return next; 1454 return next;
1490 } 1455 }
1491 } else { 1456 } else {
1492 next = bigSwitch(next); 1457 next = bigSwitch(next);
1493 } 1458 }
1494 } 1459 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 } 1860 }
1896 1861
1897 /** 1862 /**
1898 * Instances of the class `TokenWithComment` represent a normal token that is pr eceded by 1863 * Instances of the class `TokenWithComment` represent a normal token that is pr eceded by
1899 * comments. 1864 * comments.
1900 */ 1865 */
1901 class TokenWithComment extends Token { 1866 class TokenWithComment extends Token {
1902 /** 1867 /**
1903 * The first comment in the list of comments that precede this token. 1868 * The first comment in the list of comments that precede this token.
1904 */ 1869 */
1905 Token _precedingComment; 1870 final Token _precedingComment;
1906 1871
1907 /** 1872 /**
1908 * Initialize a newly created token to have the given type and offset and to b e preceded by the 1873 * Initialize a newly created token to have the given type and offset and to b e preceded by the
1909 * comments reachable from the given comment. 1874 * comments reachable from the given comment.
1910 * 1875 *
1911 * @param type the type of the token 1876 * @param type the type of the token
1912 * @param offset the offset from the beginning of the file to the first charac ter in the token 1877 * @param offset the offset from the beginning of the file to the first charac ter in the token
1913 * @param precedingComment the first comment in the list of comments that prec ede this token 1878 * @param precedingComment the first comment in the list of comments that prec ede this token
1914 */ 1879 */
1915 TokenWithComment(TokenType type, int offset, Token precedingComment) : super(t ype, offset) { 1880 TokenWithComment(TokenType type, int offset, this._precedingComment) : super(t ype, offset);
1916 this._precedingComment = precedingComment;
1917 }
1918 1881
1919 @override 1882 @override
1920 Token copy() => new TokenWithComment(type, offset, _precedingComment); 1883 Token copy() => new TokenWithComment(type, offset, _precedingComment);
1921 1884
1922 @override 1885 @override
1923 Token get precedingComments => _precedingComment; 1886 Token get precedingComments => _precedingComment;
1924 } 1887 }
1925 1888
1926 /** 1889 /**
1927 * Instances of the class `Token` represent a token that was scanned from the in put. Each 1890 * Instances of the class `Token` represent a token that was scanned from the in put. Each
1928 * token knows which token follows it, acting as the head of a linked list of to kens. 1891 * token knows which token follows it, acting as the head of a linked list of to kens.
1929 */ 1892 */
1930 class Token { 1893 class Token {
1931 /** 1894 /**
1932 * The type of the token. 1895 * The type of the token.
1933 */ 1896 */
1934 TokenType type; 1897 final TokenType type;
1935 1898
1936 /** 1899 /**
1937 * The offset from the beginning of the file to the first character in the tok en. 1900 * The offset from the beginning of the file to the first character in the tok en.
1938 */ 1901 */
1939 int offset = 0; 1902 int offset = 0;
1940 1903
1941 /** 1904 /**
1942 * The previous token in the token stream. 1905 * The previous token in the token stream.
1943 */ 1906 */
1944 Token previous; 1907 Token previous;
1945 1908
1946 /** 1909 /**
1947 * The next token in the token stream. 1910 * The next token in the token stream.
1948 */ 1911 */
1949 Token _next; 1912 Token _next;
1950 1913
1951 /** 1914 /**
1952 * Initialize a newly created token to have the given type and offset. 1915 * Initialize a newly created token to have the given type and offset.
1953 * 1916 *
1954 * @param type the type of the token 1917 * @param type the type of the token
1955 * @param offset the offset from the beginning of the file to the first charac ter in the token 1918 * @param offset the offset from the beginning of the file to the first charac ter in the token
1956 */ 1919 */
1957 Token(TokenType type, int offset) { 1920 Token(this.type, int offset) {
1958 this.type = type;
1959 this.offset = offset; 1921 this.offset = offset;
1960 } 1922 }
1961 1923
1962 /** 1924 /**
1963 * Return a newly created token that is a copy of this token but that is not a part of any token 1925 * Return a newly created token that is a copy of this token but that is not a part of any token
1964 * stream. 1926 * stream.
1965 * 1927 *
1966 * @return a newly created token that is a copy of this token 1928 * @return a newly created token that is a copy of this token
1967 */ 1929 */
1968 Token copy() => new Token(type, offset); 1930 Token copy() => new Token(type, offset);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 bool get isUserDefinableOperator => type.isUserDefinableOperator; 1991 bool get isUserDefinableOperator => type.isUserDefinableOperator;
2030 1992
2031 /** 1993 /**
2032 * Return `true` if this token has any one of the given types. 1994 * Return `true` if this token has any one of the given types.
2033 * 1995 *
2034 * @param types the types of token that are being tested for 1996 * @param types the types of token that are being tested for
2035 * @return `true` if this token has any of the given types 1997 * @return `true` if this token has any of the given types
2036 */ 1998 */
2037 bool matchesAny(List<TokenType> types) { 1999 bool matchesAny(List<TokenType> types) {
2038 for (TokenType type in types) { 2000 for (TokenType type in types) {
2039 if (identical(this.type, type)) { 2001 if (this.type == type) {
2040 return true; 2002 return true;
2041 } 2003 }
2042 } 2004 }
2043 return false; 2005 return false;
2044 } 2006 }
2045 2007
2046 /** 2008 /**
2047 * Set the next token in the token stream to the given token. This has the sid e-effect of setting 2009 * Set the next token in the token stream to the given token. This has the sid e-effect of setting
2048 * this token to be the previous token for the given token. 2010 * this token to be the previous token for the given token.
2049 * 2011 *
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2158 } 2120 }
2159 2121
2160 /** 2122 /**
2161 * Instances of the class `BeginTokenWithComment` represent a begin token that i s preceded by 2123 * Instances of the class `BeginTokenWithComment` represent a begin token that i s preceded by
2162 * comments. 2124 * comments.
2163 */ 2125 */
2164 class BeginTokenWithComment extends BeginToken { 2126 class BeginTokenWithComment extends BeginToken {
2165 /** 2127 /**
2166 * The first comment in the list of comments that precede this token. 2128 * The first comment in the list of comments that precede this token.
2167 */ 2129 */
2168 Token _precedingComment; 2130 final Token _precedingComment;
2169 2131
2170 /** 2132 /**
2171 * Initialize a newly created token to have the given type and offset and to b e preceded by the 2133 * Initialize a newly created token to have the given type and offset and to b e preceded by the
2172 * comments reachable from the given comment. 2134 * comments reachable from the given comment.
2173 * 2135 *
2174 * @param type the type of the token 2136 * @param type the type of the token
2175 * @param offset the offset from the beginning of the file to the first charac ter in the token 2137 * @param offset the offset from the beginning of the file to the first charac ter in the token
2176 * @param precedingComment the first comment in the list of comments that prec ede this token 2138 * @param precedingComment the first comment in the list of comments that prec ede this token
2177 */ 2139 */
2178 BeginTokenWithComment(TokenType type, int offset, Token precedingComment) : su per(type, offset) { 2140 BeginTokenWithComment(TokenType type, int offset, this._precedingComment) : su per(type, offset);
2179 this._precedingComment = precedingComment;
2180 }
2181 2141
2182 @override 2142 @override
2183 Token copy() => new BeginTokenWithComment(type, offset, copyComments(_precedin gComment)); 2143 Token copy() => new BeginTokenWithComment(type, offset, copyComments(_precedin gComment));
2184 2144
2185 @override 2145 @override
2186 Token get precedingComments => _precedingComment; 2146 Token get precedingComments => _precedingComment;
2187 2147
2188 @override 2148 @override
2189 void applyDelta(int delta) { 2149 void applyDelta(int delta) {
2190 super.applyDelta(delta); 2150 super.applyDelta(delta);
2191 Token token = _precedingComment; 2151 Token token = _precedingComment;
2192 while (token != null) { 2152 while (token != null) {
2193 token.applyDelta(delta); 2153 token.applyDelta(delta);
2194 token = token.next; 2154 token = token.next;
2195 } 2155 }
2196 } 2156 }
2197 } 2157 }
2198 2158
2199 /** 2159 /**
2200 * Instances of the class `KeywordToken` represent a keyword in the language. 2160 * Instances of the class `KeywordToken` represent a keyword in the language.
2201 */ 2161 */
2202 class KeywordToken extends Token { 2162 class KeywordToken extends Token {
2203 /** 2163 /**
2204 * The keyword being represented by this token. 2164 * The keyword being represented by this token.
2205 */ 2165 */
2206 Keyword keyword; 2166 final Keyword keyword;
2207 2167
2208 /** 2168 /**
2209 * Initialize a newly created token to represent the given keyword. 2169 * Initialize a newly created token to represent the given keyword.
2210 * 2170 *
2211 * @param keyword the keyword being represented by this token 2171 * @param keyword the keyword being represented by this token
2212 * @param offset the offset from the beginning of the file to the first charac ter in the token 2172 * @param offset the offset from the beginning of the file to the first charac ter in the token
2213 */ 2173 */
2214 KeywordToken(Keyword keyword, int offset) : super(TokenType.KEYWORD, offset) { 2174 KeywordToken(this.keyword, int offset) : super(TokenType.KEYWORD, offset);
2215 this.keyword = keyword;
2216 }
2217 2175
2218 @override 2176 @override
2219 Token copy() => new KeywordToken(keyword, offset); 2177 Token copy() => new KeywordToken(keyword, offset);
2220 2178
2221 @override 2179 @override
2222 String get lexeme => keyword.syntax; 2180 String get lexeme => keyword.syntax;
2223 2181
2224 @override 2182 @override
2225 Keyword value() => keyword; 2183 Keyword value() => keyword;
2226 } 2184 }
2227 2185
2228 /** 2186 /**
2229 * Instances of the class `BeginToken` represent the opening half of a grouping pair of 2187 * Instances of the class `BeginToken` represent the opening half of a grouping pair of
2230 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('['). 2188 * tokens. This is used for curly brackets ('{'), parentheses ('('), and square brackets ('[').
2231 */ 2189 */
2232 class BeginToken extends Token { 2190 class BeginToken extends Token {
2233 /** 2191 /**
2234 * The token that corresponds to this token. 2192 * The token that corresponds to this token.
2235 */ 2193 */
2236 Token endToken; 2194 Token endToken;
2237 2195
2238 /** 2196 /**
2239 * Initialize a newly created token representing the opening half of a groupin g pair of tokens. 2197 * Initialize a newly created token representing the opening half of a groupin g pair of tokens.
2240 * 2198 *
2241 * @param type the type of the token 2199 * @param type the type of the token
2242 * @param offset the offset from the beginning of the file to the first charac ter in the token 2200 * @param offset the offset from the beginning of the file to the first charac ter in the token
2243 */ 2201 */
2244 BeginToken(TokenType type, int offset) : super(type, offset) { 2202 BeginToken(TokenType type, int offset) : super(type, offset) {
2245 assert((identical(type, TokenType.OPEN_CURLY_BRACKET) || identical(type, Tok enType.OPEN_PAREN) || identical(type, TokenType.OPEN_SQUARE_BRACKET) || identica l(type, TokenType.STRING_INTERPOLATION_EXPRESSION))); 2203 assert((type == TokenType.OPEN_CURLY_BRACKET || type == TokenType.OPEN_PAREN || type == TokenType.OPEN_SQUARE_BRACKET || type == TokenType.STRING_INTERPOLAT ION_EXPRESSION));
2246 } 2204 }
2247 2205
2248 @override 2206 @override
2249 Token copy() => new BeginToken(type, offset); 2207 Token copy() => new BeginToken(type, offset);
2250 } 2208 }
2251 2209
2252 /** 2210 /**
2253 * The enumeration `TokenClass` represents classes (or groups) of tokens with a similar use. 2211 * The enumeration `TokenClass` represents classes (or groups) of tokens with a similar use.
2254 */ 2212 */
2255 class TokenClass extends Enum<TokenClass> { 2213 class TokenClass extends Enum<TokenClass> {
2256 /** 2214 /**
2257 * A value used to indicate that the token type is not part of any specific cl ass of token. 2215 * A value used to indicate that the token type is not part of any specific cl ass of token.
2258 */ 2216 */
2259 static final TokenClass NO_CLASS = new TokenClass.con1('NO_CLASS', 0); 2217 static const TokenClass NO_CLASS = const TokenClass.con1('NO_CLASS', 0);
2260 2218
2261 /** 2219 /**
2262 * A value used to indicate that the token type is an additive operator. 2220 * A value used to indicate that the token type is an additive operator.
2263 */ 2221 */
2264 static final TokenClass ADDITIVE_OPERATOR = new TokenClass.con2('ADDITIVE_OPER ATOR', 1, 12); 2222 static const TokenClass ADDITIVE_OPERATOR = const TokenClass.con2('ADDITIVE_OP ERATOR', 1, 12);
2265 2223
2266 /** 2224 /**
2267 * A value used to indicate that the token type is an assignment operator. 2225 * A value used to indicate that the token type is an assignment operator.
2268 */ 2226 */
2269 static final TokenClass ASSIGNMENT_OPERATOR = new TokenClass.con2('ASSIGNMENT_ OPERATOR', 2, 1); 2227 static const TokenClass ASSIGNMENT_OPERATOR = const TokenClass.con2('ASSIGNMEN T_OPERATOR', 2, 1);
2270 2228
2271 /** 2229 /**
2272 * A value used to indicate that the token type is a bitwise-and operator. 2230 * A value used to indicate that the token type is a bitwise-and operator.
2273 */ 2231 */
2274 static final TokenClass BITWISE_AND_OPERATOR = new TokenClass.con2('BITWISE_AN D_OPERATOR', 3, 10); 2232 static const TokenClass BITWISE_AND_OPERATOR = const TokenClass.con2('BITWISE_ AND_OPERATOR', 3, 10);
2275 2233
2276 /** 2234 /**
2277 * A value used to indicate that the token type is a bitwise-or operator. 2235 * A value used to indicate that the token type is a bitwise-or operator.
2278 */ 2236 */
2279 static final TokenClass BITWISE_OR_OPERATOR = new TokenClass.con2('BITWISE_OR_ OPERATOR', 4, 8); 2237 static const TokenClass BITWISE_OR_OPERATOR = const TokenClass.con2('BITWISE_O R_OPERATOR', 4, 8);
2280 2238
2281 /** 2239 /**
2282 * A value used to indicate that the token type is a bitwise-xor operator. 2240 * A value used to indicate that the token type is a bitwise-xor operator.
2283 */ 2241 */
2284 static final TokenClass BITWISE_XOR_OPERATOR = new TokenClass.con2('BITWISE_XO R_OPERATOR', 5, 9); 2242 static const TokenClass BITWISE_XOR_OPERATOR = const TokenClass.con2('BITWISE_ XOR_OPERATOR', 5, 9);
2285 2243
2286 /** 2244 /**
2287 * A value used to indicate that the token type is a cascade operator. 2245 * A value used to indicate that the token type is a cascade operator.
2288 */ 2246 */
2289 static final TokenClass CASCADE_OPERATOR = new TokenClass.con2('CASCADE_OPERAT OR', 6, 2); 2247 static const TokenClass CASCADE_OPERATOR = const TokenClass.con2('CASCADE_OPER ATOR', 6, 2);
2290 2248
2291 /** 2249 /**
2292 * A value used to indicate that the token type is a conditional operator. 2250 * A value used to indicate that the token type is a conditional operator.
2293 */ 2251 */
2294 static final TokenClass CONDITIONAL_OPERATOR = new TokenClass.con2('CONDITIONA L_OPERATOR', 7, 3); 2252 static const TokenClass CONDITIONAL_OPERATOR = const TokenClass.con2('CONDITIO NAL_OPERATOR', 7, 3);
2295 2253
2296 /** 2254 /**
2297 * A value used to indicate that the token type is an equality operator. 2255 * A value used to indicate that the token type is an equality operator.
2298 */ 2256 */
2299 static final TokenClass EQUALITY_OPERATOR = new TokenClass.con2('EQUALITY_OPER ATOR', 8, 6); 2257 static const TokenClass EQUALITY_OPERATOR = const TokenClass.con2('EQUALITY_OP ERATOR', 8, 6);
2300 2258
2301 /** 2259 /**
2302 * A value used to indicate that the token type is a logical-and operator. 2260 * A value used to indicate that the token type is a logical-and operator.
2303 */ 2261 */
2304 static final TokenClass LOGICAL_AND_OPERATOR = new TokenClass.con2('LOGICAL_AN D_OPERATOR', 9, 5); 2262 static const TokenClass LOGICAL_AND_OPERATOR = const TokenClass.con2('LOGICAL_ AND_OPERATOR', 9, 5);
2305 2263
2306 /** 2264 /**
2307 * A value used to indicate that the token type is a logical-or operator. 2265 * A value used to indicate that the token type is a logical-or operator.
2308 */ 2266 */
2309 static final TokenClass LOGICAL_OR_OPERATOR = new TokenClass.con2('LOGICAL_OR_ OPERATOR', 10, 4); 2267 static const TokenClass LOGICAL_OR_OPERATOR = const TokenClass.con2('LOGICAL_O R_OPERATOR', 10, 4);
2310 2268
2311 /** 2269 /**
2312 * A value used to indicate that the token type is a multiplicative operator. 2270 * A value used to indicate that the token type is a multiplicative operator.
2313 */ 2271 */
2314 static final TokenClass MULTIPLICATIVE_OPERATOR = new TokenClass.con2('MULTIPL ICATIVE_OPERATOR', 11, 13); 2272 static const TokenClass MULTIPLICATIVE_OPERATOR = const TokenClass.con2('MULTI PLICATIVE_OPERATOR', 11, 13);
2315 2273
2316 /** 2274 /**
2317 * A value used to indicate that the token type is a relational operator. 2275 * A value used to indicate that the token type is a relational operator.
2318 */ 2276 */
2319 static final TokenClass RELATIONAL_OPERATOR = new TokenClass.con2('RELATIONAL_ OPERATOR', 12, 7); 2277 static const TokenClass RELATIONAL_OPERATOR = const TokenClass.con2('RELATIONA L_OPERATOR', 12, 7);
2320 2278
2321 /** 2279 /**
2322 * A value used to indicate that the token type is a shift operator. 2280 * A value used to indicate that the token type is a shift operator.
2323 */ 2281 */
2324 static final TokenClass SHIFT_OPERATOR = new TokenClass.con2('SHIFT_OPERATOR', 13, 11); 2282 static const TokenClass SHIFT_OPERATOR = const TokenClass.con2('SHIFT_OPERATOR ', 13, 11);
2325 2283
2326 /** 2284 /**
2327 * A value used to indicate that the token type is a unary operator. 2285 * A value used to indicate that the token type is a unary operator.
2328 */ 2286 */
2329 static final TokenClass UNARY_POSTFIX_OPERATOR = new TokenClass.con2('UNARY_PO STFIX_OPERATOR', 14, 15); 2287 static const TokenClass UNARY_POSTFIX_OPERATOR = const TokenClass.con2('UNARY_ POSTFIX_OPERATOR', 14, 15);
2330 2288
2331 /** 2289 /**
2332 * A value used to indicate that the token type is a unary operator. 2290 * A value used to indicate that the token type is a unary operator.
2333 */ 2291 */
2334 static final TokenClass UNARY_PREFIX_OPERATOR = new TokenClass.con2('UNARY_PRE FIX_OPERATOR', 15, 14); 2292 static const TokenClass UNARY_PREFIX_OPERATOR = const TokenClass.con2('UNARY_P REFIX_OPERATOR', 15, 14);
2335 2293
2336 static final List<TokenClass> values = [ 2294 static const List<TokenClass> values = const [
2337 NO_CLASS, 2295 NO_CLASS,
2338 ADDITIVE_OPERATOR, 2296 ADDITIVE_OPERATOR,
2339 ASSIGNMENT_OPERATOR, 2297 ASSIGNMENT_OPERATOR,
2340 BITWISE_AND_OPERATOR, 2298 BITWISE_AND_OPERATOR,
2341 BITWISE_OR_OPERATOR, 2299 BITWISE_OR_OPERATOR,
2342 BITWISE_XOR_OPERATOR, 2300 BITWISE_XOR_OPERATOR,
2343 CASCADE_OPERATOR, 2301 CASCADE_OPERATOR,
2344 CONDITIONAL_OPERATOR, 2302 CONDITIONAL_OPERATOR,
2345 EQUALITY_OPERATOR, 2303 EQUALITY_OPERATOR,
2346 LOGICAL_AND_OPERATOR, 2304 LOGICAL_AND_OPERATOR,
2347 LOGICAL_OR_OPERATOR, 2305 LOGICAL_OR_OPERATOR,
2348 MULTIPLICATIVE_OPERATOR, 2306 MULTIPLICATIVE_OPERATOR,
2349 RELATIONAL_OPERATOR, 2307 RELATIONAL_OPERATOR,
2350 SHIFT_OPERATOR, 2308 SHIFT_OPERATOR,
2351 UNARY_POSTFIX_OPERATOR, 2309 UNARY_POSTFIX_OPERATOR,
2352 UNARY_PREFIX_OPERATOR]; 2310 UNARY_PREFIX_OPERATOR];
2353 2311
2354 /** 2312 /**
2355 * The precedence of tokens of this class, or `0` if the such tokens do not re present an 2313 * The precedence of tokens of this class, or `0` if the such tokens do not re present an
2356 * operator. 2314 * operator.
2357 */ 2315 */
2358 int _precedence = 0; 2316 final int precedence;
2359 2317
2360 TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0); 2318 const TokenClass.con1(String name, int ordinal) : this.con2(name, ordinal, 0);
2361 2319
2362 TokenClass.con2(String name, int ordinal, int precedence) : super(name, ordina l) { 2320 const TokenClass.con2(String name, int ordinal, this.precedence) : super(name, ordinal);
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;
2373 } 2321 }
2374 2322
2375 /** 2323 /**
2376 * Instances of the class `KeywordTokenWithComment` implement a keyword token th at is preceded 2324 * Instances of the class `KeywordTokenWithComment` implement a keyword token th at is preceded
2377 * by comments. 2325 * by comments.
2378 */ 2326 */
2379 class KeywordTokenWithComment extends KeywordToken { 2327 class KeywordTokenWithComment extends KeywordToken {
2380 /** 2328 /**
2381 * The first comment in the list of comments that precede this token. 2329 * The first comment in the list of comments that precede this token.
2382 */ 2330 */
2383 Token _precedingComment; 2331 final Token _precedingComment;
2384 2332
2385 /** 2333 /**
2386 * Initialize a newly created token to to represent the given keyword and to b e preceded by the 2334 * Initialize a newly created token to to represent the given keyword and to b e preceded by the
2387 * comments reachable from the given comment. 2335 * comments reachable from the given comment.
2388 * 2336 *
2389 * @param keyword the keyword being represented by this token 2337 * @param keyword the keyword being represented by this token
2390 * @param offset the offset from the beginning of the file to the first charac ter in the token 2338 * @param offset the offset from the beginning of the file to the first charac ter in the token
2391 * @param precedingComment the first comment in the list of comments that prec ede this token 2339 * @param precedingComment the first comment in the list of comments that prec ede this token
2392 */ 2340 */
2393 KeywordTokenWithComment(Keyword keyword, int offset, Token precedingComment) : super(keyword, offset) { 2341 KeywordTokenWithComment(Keyword keyword, int offset, this._precedingComment) : super(keyword, offset);
2394 this._precedingComment = precedingComment;
2395 }
2396 2342
2397 @override 2343 @override
2398 Token copy() => new KeywordTokenWithComment(keyword, offset, copyComments(_pre cedingComment)); 2344 Token copy() => new KeywordTokenWithComment(keyword, offset, copyComments(_pre cedingComment));
2399 2345
2400 @override 2346 @override
2401 Token get precedingComments => _precedingComment; 2347 Token get precedingComments => _precedingComment;
2402 2348
2403 @override 2349 @override
2404 void applyDelta(int delta) { 2350 void applyDelta(int delta) {
2405 super.applyDelta(delta); 2351 super.applyDelta(delta);
2406 Token token = _precedingComment; 2352 Token token = _precedingComment;
2407 while (token != null) { 2353 while (token != null) {
2408 token.applyDelta(delta); 2354 token.applyDelta(delta);
2409 token = token.next; 2355 token = token.next;
2410 } 2356 }
2411 } 2357 }
2412 } 2358 }
2413 2359
2414 /** 2360 /**
2415 * The enumeration `TokenType` defines the types of tokens that can be returned by the 2361 * The enumeration `TokenType` defines the types of tokens that can be returned by the
2416 * scanner. 2362 * scanner.
2417 */ 2363 */
2418 class TokenType extends Enum<TokenType> { 2364 class TokenType extends Enum<TokenType> {
2419 /** 2365 /**
2420 * The type of the token that marks the end of the input. 2366 * The type of the token that marks the end of the input.
2421 */ 2367 */
2422 static final TokenType EOF = new TokenType_EOF('EOF', 0, null, ""); 2368 static const TokenType EOF = const TokenType_EOF('EOF', 0, TokenClass.NO_CLASS , "");
2423 2369
2424 static final TokenType DOUBLE = new TokenType.con1('DOUBLE', 1); 2370 static const TokenType DOUBLE = const TokenType.con1('DOUBLE', 1);
2425 2371
2426 static final TokenType HEXADECIMAL = new TokenType.con1('HEXADECIMAL', 2); 2372 static const TokenType HEXADECIMAL = const TokenType.con1('HEXADECIMAL', 2);
2427 2373
2428 static final TokenType IDENTIFIER = new TokenType.con1('IDENTIFIER', 3); 2374 static const TokenType IDENTIFIER = const TokenType.con1('IDENTIFIER', 3);
2429 2375
2430 static final TokenType INT = new TokenType.con1('INT', 4); 2376 static const TokenType INT = const TokenType.con1('INT', 4);
2431 2377
2432 static final TokenType KEYWORD = new TokenType.con1('KEYWORD', 5); 2378 static const TokenType KEYWORD = const TokenType.con1('KEYWORD', 5);
2433 2379
2434 static final TokenType MULTI_LINE_COMMENT = new TokenType.con1('MULTI_LINE_COM MENT', 6); 2380 static const TokenType MULTI_LINE_COMMENT = const TokenType.con1('MULTI_LINE_C OMMENT', 6);
2435 2381
2436 static final TokenType SCRIPT_TAG = new TokenType.con1('SCRIPT_TAG', 7); 2382 static const TokenType SCRIPT_TAG = const TokenType.con1('SCRIPT_TAG', 7);
2437 2383
2438 static final TokenType SINGLE_LINE_COMMENT = new TokenType.con1('SINGLE_LINE_C OMMENT', 8); 2384 static const TokenType SINGLE_LINE_COMMENT = const TokenType.con1('SINGLE_LINE _COMMENT', 8);
2439 2385
2440 static final TokenType STRING = new TokenType.con1('STRING', 9); 2386 static const TokenType STRING = const TokenType.con1('STRING', 9);
2441 2387
2442 static final TokenType AMPERSAND = new TokenType.con2('AMPERSAND', 10, TokenCl ass.BITWISE_AND_OPERATOR, "&"); 2388 static const TokenType AMPERSAND = const TokenType.con2('AMPERSAND', 10, Token Class.BITWISE_AND_OPERATOR, "&");
2443 2389
2444 static final TokenType AMPERSAND_AMPERSAND = new TokenType.con2('AMPERSAND_AMP ERSAND', 11, TokenClass.LOGICAL_AND_OPERATOR, "&&"); 2390 static const TokenType AMPERSAND_AMPERSAND = const TokenType.con2('AMPERSAND_A MPERSAND', 11, TokenClass.LOGICAL_AND_OPERATOR, "&&");
2445 2391
2446 static final TokenType AMPERSAND_EQ = new TokenType.con2('AMPERSAND_EQ', 12, T okenClass.ASSIGNMENT_OPERATOR, "&="); 2392 static const TokenType AMPERSAND_EQ = const TokenType.con2('AMPERSAND_EQ', 12, TokenClass.ASSIGNMENT_OPERATOR, "&=");
2447 2393
2448 static final TokenType AT = new TokenType.con2('AT', 13, null, "@"); 2394 static const TokenType AT = const TokenType.con2('AT', 13, TokenClass.NO_CLASS , "@");
2449 2395
2450 static final TokenType BANG = new TokenType.con2('BANG', 14, TokenClass.UNARY_ PREFIX_OPERATOR, "!"); 2396 static const TokenType BANG = const TokenType.con2('BANG', 14, TokenClass.UNAR Y_PREFIX_OPERATOR, "!");
2451 2397
2452 static final TokenType BANG_EQ = new TokenType.con2('BANG_EQ', 15, TokenClass. EQUALITY_OPERATOR, "!="); 2398 static const TokenType BANG_EQ = const TokenType.con2('BANG_EQ', 15, TokenClas s.EQUALITY_OPERATOR, "!=");
2453 2399
2454 static final TokenType BAR = new TokenType.con2('BAR', 16, TokenClass.BITWISE_ OR_OPERATOR, "|"); 2400 static const TokenType BAR = const TokenType.con2('BAR', 16, TokenClass.BITWIS E_OR_OPERATOR, "|");
2455 2401
2456 static final TokenType BAR_BAR = new TokenType.con2('BAR_BAR', 17, TokenClass. LOGICAL_OR_OPERATOR, "||"); 2402 static const TokenType BAR_BAR = const TokenType.con2('BAR_BAR', 17, TokenClas s.LOGICAL_OR_OPERATOR, "||");
2457 2403
2458 static final TokenType BAR_EQ = new TokenType.con2('BAR_EQ', 18, TokenClass.AS SIGNMENT_OPERATOR, "|="); 2404 static const TokenType BAR_EQ = const TokenType.con2('BAR_EQ', 18, TokenClass. ASSIGNMENT_OPERATOR, "|=");
2459 2405
2460 static final TokenType COLON = new TokenType.con2('COLON', 19, null, ":"); 2406 static const TokenType COLON = const TokenType.con2('COLON', 19, TokenClass.NO _CLASS, ":");
2461 2407
2462 static final TokenType COMMA = new TokenType.con2('COMMA', 20, null, ","); 2408 static const TokenType COMMA = const TokenType.con2('COMMA', 20, TokenClass.NO _CLASS, ",");
2463 2409
2464 static final TokenType CARET = new TokenType.con2('CARET', 21, TokenClass.BITW ISE_XOR_OPERATOR, "^"); 2410 static const TokenType CARET = const TokenType.con2('CARET', 21, TokenClass.BI TWISE_XOR_OPERATOR, "^");
2465 2411
2466 static final TokenType CARET_EQ = new TokenType.con2('CARET_EQ', 22, TokenClas s.ASSIGNMENT_OPERATOR, "^="); 2412 static const TokenType CARET_EQ = const TokenType.con2('CARET_EQ', 22, TokenCl ass.ASSIGNMENT_OPERATOR, "^=");
2467 2413
2468 static final TokenType CLOSE_CURLY_BRACKET = new TokenType.con2('CLOSE_CURLY_B RACKET', 23, null, "}"); 2414 static const TokenType CLOSE_CURLY_BRACKET = const TokenType.con2('CLOSE_CURLY _BRACKET', 23, TokenClass.NO_CLASS, "}");
2469 2415
2470 static final TokenType CLOSE_PAREN = new TokenType.con2('CLOSE_PAREN', 24, nul l, ")"); 2416 static const TokenType CLOSE_PAREN = const TokenType.con2('CLOSE_PAREN', 24, T okenClass.NO_CLASS, ")");
2471 2417
2472 static final TokenType CLOSE_SQUARE_BRACKET = new TokenType.con2('CLOSE_SQUARE _BRACKET', 25, null, "]"); 2418 static const TokenType CLOSE_SQUARE_BRACKET = const TokenType.con2('CLOSE_SQUA RE_BRACKET', 25, TokenClass.NO_CLASS, "]");
2473 2419
2474 static final TokenType EQ = new TokenType.con2('EQ', 26, TokenClass.ASSIGNMENT _OPERATOR, "="); 2420 static const TokenType EQ = const TokenType.con2('EQ', 26, TokenClass.ASSIGNME NT_OPERATOR, "=");
2475 2421
2476 static final TokenType EQ_EQ = new TokenType.con2('EQ_EQ', 27, TokenClass.EQUA LITY_OPERATOR, "=="); 2422 static const TokenType EQ_EQ = const TokenType.con2('EQ_EQ', 27, TokenClass.EQ UALITY_OPERATOR, "==");
2477 2423
2478 static final TokenType FUNCTION = new TokenType.con2('FUNCTION', 28, null, "=> "); 2424 static const TokenType FUNCTION = const TokenType.con2('FUNCTION', 28, TokenCl ass.NO_CLASS, "=>");
2479 2425
2480 static final TokenType GT = new TokenType.con2('GT', 29, TokenClass.RELATIONAL _OPERATOR, ">"); 2426 static const TokenType GT = const TokenType.con2('GT', 29, TokenClass.RELATION AL_OPERATOR, ">");
2481 2427
2482 static final TokenType GT_EQ = new TokenType.con2('GT_EQ', 30, TokenClass.RELA TIONAL_OPERATOR, ">="); 2428 static const TokenType GT_EQ = const TokenType.con2('GT_EQ', 30, TokenClass.RE LATIONAL_OPERATOR, ">=");
2483 2429
2484 static final TokenType GT_GT = new TokenType.con2('GT_GT', 31, TokenClass.SHIF T_OPERATOR, ">>"); 2430 static const TokenType GT_GT = const TokenType.con2('GT_GT', 31, TokenClass.SH IFT_OPERATOR, ">>");
2485 2431
2486 static final TokenType GT_GT_EQ = new TokenType.con2('GT_GT_EQ', 32, TokenClas s.ASSIGNMENT_OPERATOR, ">>="); 2432 static const TokenType GT_GT_EQ = const TokenType.con2('GT_GT_EQ', 32, TokenCl ass.ASSIGNMENT_OPERATOR, ">>=");
2487 2433
2488 static final TokenType HASH = new TokenType.con2('HASH', 33, null, "#"); 2434 static const TokenType HASH = const TokenType.con2('HASH', 33, TokenClass.NO_C LASS, "#");
2489 2435
2490 static final TokenType INDEX = new TokenType.con2('INDEX', 34, TokenClass.UNAR Y_POSTFIX_OPERATOR, "[]"); 2436 static const TokenType INDEX = const TokenType.con2('INDEX', 34, TokenClass.UN ARY_POSTFIX_OPERATOR, "[]");
2491 2437
2492 static final TokenType INDEX_EQ = new TokenType.con2('INDEX_EQ', 35, TokenClas s.UNARY_POSTFIX_OPERATOR, "[]="); 2438 static const TokenType INDEX_EQ = const TokenType.con2('INDEX_EQ', 35, TokenCl ass.UNARY_POSTFIX_OPERATOR, "[]=");
2493 2439
2494 static final TokenType IS = new TokenType.con2('IS', 36, TokenClass.RELATIONAL _OPERATOR, "is"); 2440 static const TokenType IS = const TokenType.con2('IS', 36, TokenClass.RELATION AL_OPERATOR, "is");
2495 2441
2496 static final TokenType LT = new TokenType.con2('LT', 37, TokenClass.RELATIONAL _OPERATOR, "<"); 2442 static const TokenType LT = const TokenType.con2('LT', 37, TokenClass.RELATION AL_OPERATOR, "<");
2497 2443
2498 static final TokenType LT_EQ = new TokenType.con2('LT_EQ', 38, TokenClass.RELA TIONAL_OPERATOR, "<="); 2444 static const TokenType LT_EQ = const TokenType.con2('LT_EQ', 38, TokenClass.RE LATIONAL_OPERATOR, "<=");
2499 2445
2500 static final TokenType LT_LT = new TokenType.con2('LT_LT', 39, TokenClass.SHIF T_OPERATOR, "<<"); 2446 static const TokenType LT_LT = const TokenType.con2('LT_LT', 39, TokenClass.SH IFT_OPERATOR, "<<");
2501 2447
2502 static final TokenType LT_LT_EQ = new TokenType.con2('LT_LT_EQ', 40, TokenClas s.ASSIGNMENT_OPERATOR, "<<="); 2448 static const TokenType LT_LT_EQ = const TokenType.con2('LT_LT_EQ', 40, TokenCl ass.ASSIGNMENT_OPERATOR, "<<=");
2503 2449
2504 static final TokenType MINUS = new TokenType.con2('MINUS', 41, TokenClass.ADDI TIVE_OPERATOR, "-"); 2450 static const TokenType MINUS = const TokenType.con2('MINUS', 41, TokenClass.AD DITIVE_OPERATOR, "-");
2505 2451
2506 static final TokenType MINUS_EQ = new TokenType.con2('MINUS_EQ', 42, TokenClas s.ASSIGNMENT_OPERATOR, "-="); 2452 static const TokenType MINUS_EQ = const TokenType.con2('MINUS_EQ', 42, TokenCl ass.ASSIGNMENT_OPERATOR, "-=");
2507 2453
2508 static final TokenType MINUS_MINUS = new TokenType.con2('MINUS_MINUS', 43, Tok enClass.UNARY_PREFIX_OPERATOR, "--"); 2454 static const TokenType MINUS_MINUS = const TokenType.con2('MINUS_MINUS', 43, T okenClass.UNARY_PREFIX_OPERATOR, "--");
2509 2455
2510 static final TokenType OPEN_CURLY_BRACKET = new TokenType.con2('OPEN_CURLY_BRA CKET', 44, null, "{"); 2456 static const TokenType OPEN_CURLY_BRACKET = const TokenType.con2('OPEN_CURLY_B RACKET', 44, TokenClass.NO_CLASS, "{");
2511 2457
2512 static final TokenType OPEN_PAREN = new TokenType.con2('OPEN_PAREN', 45, Token Class.UNARY_POSTFIX_OPERATOR, "("); 2458 static const TokenType OPEN_PAREN = const TokenType.con2('OPEN_PAREN', 45, Tok enClass.UNARY_POSTFIX_OPERATOR, "(");
2513 2459
2514 static final TokenType OPEN_SQUARE_BRACKET = new TokenType.con2('OPEN_SQUARE_B RACKET', 46, TokenClass.UNARY_POSTFIX_OPERATOR, "["); 2460 static const TokenType OPEN_SQUARE_BRACKET = const TokenType.con2('OPEN_SQUARE _BRACKET', 46, TokenClass.UNARY_POSTFIX_OPERATOR, "[");
2515 2461
2516 static final TokenType PERCENT = new TokenType.con2('PERCENT', 47, TokenClass. MULTIPLICATIVE_OPERATOR, "%"); 2462 static const TokenType PERCENT = const TokenType.con2('PERCENT', 47, TokenClas s.MULTIPLICATIVE_OPERATOR, "%");
2517 2463
2518 static final TokenType PERCENT_EQ = new TokenType.con2('PERCENT_EQ', 48, Token Class.ASSIGNMENT_OPERATOR, "%="); 2464 static const TokenType PERCENT_EQ = const TokenType.con2('PERCENT_EQ', 48, Tok enClass.ASSIGNMENT_OPERATOR, "%=");
2519 2465
2520 static final TokenType PERIOD = new TokenType.con2('PERIOD', 49, TokenClass.UN ARY_POSTFIX_OPERATOR, "."); 2466 static const TokenType PERIOD = const TokenType.con2('PERIOD', 49, TokenClass. UNARY_POSTFIX_OPERATOR, ".");
2521 2467
2522 static final TokenType PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIOD', 50, TokenClass.CASCADE_OPERATOR, ".."); 2468 static const TokenType PERIOD_PERIOD = const TokenType.con2('PERIOD_PERIOD', 5 0, TokenClass.CASCADE_OPERATOR, "..");
2523 2469
2524 static final TokenType PLUS = new TokenType.con2('PLUS', 51, TokenClass.ADDITI VE_OPERATOR, "+"); 2470 static const TokenType PLUS = const TokenType.con2('PLUS', 51, TokenClass.ADDI TIVE_OPERATOR, "+");
2525 2471
2526 static final TokenType PLUS_EQ = new TokenType.con2('PLUS_EQ', 52, TokenClass. ASSIGNMENT_OPERATOR, "+="); 2472 static const TokenType PLUS_EQ = const TokenType.con2('PLUS_EQ', 52, TokenClas s.ASSIGNMENT_OPERATOR, "+=");
2527 2473
2528 static final TokenType PLUS_PLUS = new TokenType.con2('PLUS_PLUS', 53, TokenCl ass.UNARY_PREFIX_OPERATOR, "++"); 2474 static const TokenType PLUS_PLUS = const TokenType.con2('PLUS_PLUS', 53, Token Class.UNARY_PREFIX_OPERATOR, "++");
2529 2475
2530 static final TokenType QUESTION = new TokenType.con2('QUESTION', 54, TokenClas s.CONDITIONAL_OPERATOR, "?"); 2476 static const TokenType QUESTION = const TokenType.con2('QUESTION', 54, TokenCl ass.CONDITIONAL_OPERATOR, "?");
2531 2477
2532 static final TokenType SEMICOLON = new TokenType.con2('SEMICOLON', 55, null, " ;"); 2478 static const TokenType SEMICOLON = const TokenType.con2('SEMICOLON', 55, Token Class.NO_CLASS, ";");
2533 2479
2534 static final TokenType SLASH = new TokenType.con2('SLASH', 56, TokenClass.MULT IPLICATIVE_OPERATOR, "/"); 2480 static const TokenType SLASH = const TokenType.con2('SLASH', 56, TokenClass.MU LTIPLICATIVE_OPERATOR, "/");
2535 2481
2536 static final TokenType SLASH_EQ = new TokenType.con2('SLASH_EQ', 57, TokenClas s.ASSIGNMENT_OPERATOR, "/="); 2482 static const TokenType SLASH_EQ = const TokenType.con2('SLASH_EQ', 57, TokenCl ass.ASSIGNMENT_OPERATOR, "/=");
2537 2483
2538 static final TokenType STAR = new TokenType.con2('STAR', 58, TokenClass.MULTIP LICATIVE_OPERATOR, "*"); 2484 static const TokenType STAR = const TokenType.con2('STAR', 58, TokenClass.MULT IPLICATIVE_OPERATOR, "*");
2539 2485
2540 static final TokenType STAR_EQ = new TokenType.con2('STAR_EQ', 59, TokenClass. ASSIGNMENT_OPERATOR, "*="); 2486 static const TokenType STAR_EQ = const TokenType.con2('STAR_EQ', 59, TokenClas s.ASSIGNMENT_OPERATOR, "*=");
2541 2487
2542 static final TokenType STRING_INTERPOLATION_EXPRESSION = new TokenType.con2('S TRING_INTERPOLATION_EXPRESSION', 60, null, "\${"); 2488 static const TokenType STRING_INTERPOLATION_EXPRESSION = const TokenType.con2( 'STRING_INTERPOLATION_EXPRESSION', 60, TokenClass.NO_CLASS, "\${");
2543 2489
2544 static final TokenType STRING_INTERPOLATION_IDENTIFIER = new TokenType.con2('S TRING_INTERPOLATION_IDENTIFIER', 61, null, "\$"); 2490 static const TokenType STRING_INTERPOLATION_IDENTIFIER = const TokenType.con2( 'STRING_INTERPOLATION_IDENTIFIER', 61, TokenClass.NO_CLASS, "\$");
2545 2491
2546 static final TokenType TILDE = new TokenType.con2('TILDE', 62, TokenClass.UNAR Y_PREFIX_OPERATOR, "~"); 2492 static const TokenType TILDE = const TokenType.con2('TILDE', 62, TokenClass.UN ARY_PREFIX_OPERATOR, "~");
2547 2493
2548 static final TokenType TILDE_SLASH = new TokenType.con2('TILDE_SLASH', 63, Tok enClass.MULTIPLICATIVE_OPERATOR, "~/"); 2494 static const TokenType TILDE_SLASH = const TokenType.con2('TILDE_SLASH', 63, T okenClass.MULTIPLICATIVE_OPERATOR, "~/");
2549 2495
2550 static final TokenType TILDE_SLASH_EQ = new TokenType.con2('TILDE_SLASH_EQ', 6 4, TokenClass.ASSIGNMENT_OPERATOR, "~/="); 2496 static const TokenType TILDE_SLASH_EQ = const TokenType.con2('TILDE_SLASH_EQ', 64, TokenClass.ASSIGNMENT_OPERATOR, "~/=");
2551 2497
2552 static final TokenType BACKPING = new TokenType.con2('BACKPING', 65, null, "`" ); 2498 static const TokenType BACKPING = const TokenType.con2('BACKPING', 65, TokenCl ass.NO_CLASS, "`");
2553 2499
2554 static final TokenType BACKSLASH = new TokenType.con2('BACKSLASH', 66, null, " \\"); 2500 static const TokenType BACKSLASH = const TokenType.con2('BACKSLASH', 66, Token Class.NO_CLASS, "\\");
2555 2501
2556 static final TokenType PERIOD_PERIOD_PERIOD = new TokenType.con2('PERIOD_PERIO D_PERIOD', 67, null, "..."); 2502 static const TokenType PERIOD_PERIOD_PERIOD = const TokenType.con2('PERIOD_PER IOD_PERIOD', 67, TokenClass.NO_CLASS, "...");
2557 2503
2558 static final List<TokenType> values = [ 2504 static const List<TokenType> values = const [
2559 EOF, 2505 EOF,
2560 DOUBLE, 2506 DOUBLE,
2561 HEXADECIMAL, 2507 HEXADECIMAL,
2562 IDENTIFIER, 2508 IDENTIFIER,
2563 INT, 2509 INT,
2564 KEYWORD, 2510 KEYWORD,
2565 MULTI_LINE_COMMENT, 2511 MULTI_LINE_COMMENT,
2566 SCRIPT_TAG, 2512 SCRIPT_TAG,
2567 SINGLE_LINE_COMMENT, 2513 SINGLE_LINE_COMMENT,
2568 STRING, 2514 STRING,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 TILDE, 2567 TILDE,
2622 TILDE_SLASH, 2568 TILDE_SLASH,
2623 TILDE_SLASH_EQ, 2569 TILDE_SLASH_EQ,
2624 BACKPING, 2570 BACKPING,
2625 BACKSLASH, 2571 BACKSLASH,
2626 PERIOD_PERIOD_PERIOD]; 2572 PERIOD_PERIOD_PERIOD];
2627 2573
2628 /** 2574 /**
2629 * The class of the token. 2575 * The class of the token.
2630 */ 2576 */
2631 TokenClass _tokenClass; 2577 final TokenClass _tokenClass;
2632 2578
2633 /** 2579 /**
2634 * The lexeme that defines this type of token, or `null` if there is more than one possible 2580 * The lexeme that defines this type of token, or `null` if there is more than one possible
2635 * lexeme for this type of token. 2581 * lexeme for this type of token.
2636 */ 2582 */
2637 String _lexeme; 2583 final String lexeme;
2638 2584
2639 TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, TokenClass .NO_CLASS, null); 2585 const TokenType.con1(String name, int ordinal) : this.con2(name, ordinal, Toke nClass.NO_CLASS, null);
2640 2586
2641 TokenType.con2(String name, int ordinal, TokenClass tokenClass, String lexeme) : super(name, ordinal) { 2587 const TokenType.con2(String name, int ordinal, this._tokenClass, this.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;
2653 2588
2654 /** 2589 /**
2655 * Return the precedence of the token, or `0` if the token does not represent an operator. 2590 * Return the precedence of the token, or `0` if the token does not represent an operator.
2656 * 2591 *
2657 * @return the precedence of the token 2592 * @return the precedence of the token
2658 */ 2593 */
2659 int get precedence => _tokenClass.precedence; 2594 int get precedence => _tokenClass.precedence;
2660 2595
2661 /** 2596 /**
2662 * Return `true` if this type of token represents an additive operator. 2597 * Return `true` if this type of token represents an additive operator.
2663 * 2598 *
2664 * @return `true` if this type of token represents an additive operator 2599 * @return `true` if this type of token represents an additive operator
2665 */ 2600 */
2666 bool get isAdditiveOperator => identical(_tokenClass, TokenClass.ADDITIVE_OPER ATOR); 2601 bool get isAdditiveOperator => _tokenClass == TokenClass.ADDITIVE_OPERATOR;
2667 2602
2668 /** 2603 /**
2669 * Return `true` if this type of token represents an assignment operator. 2604 * Return `true` if this type of token represents an assignment operator.
2670 * 2605 *
2671 * @return `true` if this type of token represents an assignment operator 2606 * @return `true` if this type of token represents an assignment operator
2672 */ 2607 */
2673 bool get isAssignmentOperator => identical(_tokenClass, TokenClass.ASSIGNMENT_ OPERATOR); 2608 bool get isAssignmentOperator => _tokenClass == TokenClass.ASSIGNMENT_OPERATOR ;
2674 2609
2675 /** 2610 /**
2676 * Return `true` if this type of token represents an associative operator. An associative 2611 * Return `true` if this type of token represents an associative operator. An associative
2677 * operator is an operator for which the following equality is true: 2612 * operator is an operator for which the following equality is true:
2678 * `(a * b) * c == a * (b * c)`. In other words, if the result of applying the operator to 2613 * `(a * b) * c == a * (b * c)`. In other words, if the result of applying the operator to
2679 * multiple operands does not depend on the order in which those applications occur. 2614 * multiple operands does not depend on the order in which those applications occur.
2680 * 2615 *
2681 * Note: This method considers the logical-and and logical-or operators to be associative, even 2616 * Note: This method considers the logical-and and logical-or operators to be associative, even
2682 * though the order in which the application of those operators can have an ef fect because 2617 * though the order in which the application of those operators can have an ef fect because
2683 * evaluation of the right-hand operand is conditional. 2618 * evaluation of the right-hand operand is conditional.
2684 * 2619 *
2685 * @return `true` if this type of token represents an associative operator 2620 * @return `true` if this type of token represents an associative operator
2686 */ 2621 */
2687 bool get isAssociativeOperator => identical(this, AMPERSAND) || identical(this , AMPERSAND_AMPERSAND) || identical(this, BAR) || identical(this, BAR_BAR) || id entical(this, CARET) || identical(this, PLUS) || identical(this, STAR); 2622 bool get isAssociativeOperator => this == AMPERSAND || this == AMPERSAND_AMPER SAND || this == BAR || this == BAR_BAR || this == CARET || this == PLUS || this == STAR;
2688 2623
2689 /** 2624 /**
2690 * Return `true` if this type of token represents an equality operator. 2625 * Return `true` if this type of token represents an equality operator.
2691 * 2626 *
2692 * @return `true` if this type of token represents an equality operator 2627 * @return `true` if this type of token represents an equality operator
2693 */ 2628 */
2694 bool get isEqualityOperator => identical(_tokenClass, TokenClass.EQUALITY_OPER ATOR); 2629 bool get isEqualityOperator => _tokenClass == TokenClass.EQUALITY_OPERATOR;
2695 2630
2696 /** 2631 /**
2697 * Return `true` if this type of token represents an increment operator. 2632 * Return `true` if this type of token represents an increment operator.
2698 * 2633 *
2699 * @return `true` if this type of token represents an increment operator 2634 * @return `true` if this type of token represents an increment operator
2700 */ 2635 */
2701 bool get isIncrementOperator => identical(_lexeme, "++") || identical(_lexeme, "--"); 2636 bool get isIncrementOperator => identical(lexeme, "++") || identical(lexeme, " --");
2702 2637
2703 /** 2638 /**
2704 * Return `true` if this type of token represents a multiplicative operator. 2639 * Return `true` if this type of token represents a multiplicative operator.
2705 * 2640 *
2706 * @return `true` if this type of token represents a multiplicative operator 2641 * @return `true` if this type of token represents a multiplicative operator
2707 */ 2642 */
2708 bool get isMultiplicativeOperator => identical(_tokenClass, TokenClass.MULTIPL ICATIVE_OPERATOR); 2643 bool get isMultiplicativeOperator => _tokenClass == TokenClass.MULTIPLICATIVE_ OPERATOR;
2709 2644
2710 /** 2645 /**
2711 * Return `true` if this token type represents an operator. 2646 * Return `true` if this token type represents an operator.
2712 * 2647 *
2713 * @return `true` if this token type represents an operator 2648 * @return `true` if this token type represents an operator
2714 */ 2649 */
2715 bool get isOperator => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PARE N && this != OPEN_SQUARE_BRACKET && this != PERIOD; 2650 bool get isOperator => _tokenClass != TokenClass.NO_CLASS && this != OPEN_PARE N && this != OPEN_SQUARE_BRACKET && this != PERIOD;
2716 2651
2717 /** 2652 /**
2718 * Return `true` if this type of token represents a relational operator. 2653 * Return `true` if this type of token represents a relational operator.
2719 * 2654 *
2720 * @return `true` if this type of token represents a relational operator 2655 * @return `true` if this type of token represents a relational operator
2721 */ 2656 */
2722 bool get isRelationalOperator => identical(_tokenClass, TokenClass.RELATIONAL_ OPERATOR); 2657 bool get isRelationalOperator => _tokenClass == TokenClass.RELATIONAL_OPERATOR ;
2723 2658
2724 /** 2659 /**
2725 * Return `true` if this type of token represents a shift operator. 2660 * Return `true` if this type of token represents a shift operator.
2726 * 2661 *
2727 * @return `true` if this type of token represents a shift operator 2662 * @return `true` if this type of token represents a shift operator
2728 */ 2663 */
2729 bool get isShiftOperator => identical(_tokenClass, TokenClass.SHIFT_OPERATOR); 2664 bool get isShiftOperator => _tokenClass == TokenClass.SHIFT_OPERATOR;
2730 2665
2731 /** 2666 /**
2732 * Return `true` if this type of token represents a unary postfix operator. 2667 * Return `true` if this type of token represents a unary postfix operator.
2733 * 2668 *
2734 * @return `true` if this type of token represents a unary postfix operator 2669 * @return `true` if this type of token represents a unary postfix operator
2735 */ 2670 */
2736 bool get isUnaryPostfixOperator => identical(_tokenClass, TokenClass.UNARY_POS TFIX_OPERATOR); 2671 bool get isUnaryPostfixOperator => _tokenClass == TokenClass.UNARY_POSTFIX_OPE RATOR;
2737 2672
2738 /** 2673 /**
2739 * Return `true` if this type of token represents a unary prefix operator. 2674 * Return `true` if this type of token represents a unary prefix operator.
2740 * 2675 *
2741 * @return `true` if this type of token represents a unary prefix operator 2676 * @return `true` if this type of token represents a unary prefix operator
2742 */ 2677 */
2743 bool get isUnaryPrefixOperator => identical(_tokenClass, TokenClass.UNARY_PREF IX_OPERATOR); 2678 bool get isUnaryPrefixOperator => _tokenClass == TokenClass.UNARY_PREFIX_OPERA TOR;
2744 2679
2745 /** 2680 /**
2746 * Return `true` if this token type represents an operator that can be defined by users. 2681 * Return `true` if this token type represents an operator that can be defined by users.
2747 * 2682 *
2748 * @return `true` if this token type represents an operator that can be define d by users 2683 * @return `true` if this token type represents an operator that can be define d by users
2749 */ 2684 */
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, "|"); 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, "|");
2751 } 2686 }
2752 2687
2753 class TokenType_EOF extends TokenType { 2688 class TokenType_EOF extends TokenType {
2754 TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super. con2(name, ordinal, arg0, arg1); 2689 const TokenType_EOF(String name, int ordinal, TokenClass arg0, String arg1) : super.con2(name, ordinal, arg0, arg1);
2755 2690
2756 @override 2691 @override
2757 String toString() => "-eof-"; 2692 String toString() => "-eof-";
2758 } 2693 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/lib/src/generated/sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698