| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Defines the tokens that are produced by the scanner, used by the parser, and | 6 * Defines the tokens that are produced by the scanner, used by the parser, and |
| 7 * referenced from the [AST structure](ast.dart). | 7 * referenced from the [AST structure](ast.dart). |
| 8 */ | 8 */ |
| 9 library analyzer.dart.ast.token; | 9 library analyzer.dart.ast.token; |
| 10 | 10 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 /** | 353 /** |
| 354 * Compare the given [tokens] to find the token that appears first in the | 354 * Compare the given [tokens] to find the token that appears first in the |
| 355 * source being parsed. That is, return the left-most of all of the tokens. | 355 * source being parsed. That is, return the left-most of all of the tokens. |
| 356 * The list must be non-`null`, but the elements of the list are allowed to be | 356 * The list must be non-`null`, but the elements of the list are allowed to be |
| 357 * `null`. Return the token with the smallest offset, or `null` if the list is | 357 * `null`. Return the token with the smallest offset, or `null` if the list is |
| 358 * empty or if all of the elements of the list are `null`. | 358 * empty or if all of the elements of the list are `null`. |
| 359 */ | 359 */ |
| 360 static Token lexicallyFirst(List<Token> tokens) { | 360 static Token lexicallyFirst(List<Token> tokens) { |
| 361 Token first = null; | 361 Token first = null; |
| 362 int offset = -1; | 362 int offset = -1; |
| 363 for (Token token in tokens) { | 363 int length = tokens.length; |
| 364 for (int i = 0; i < length; i++) { |
| 365 Token token = tokens[i]; |
| 364 if (token != null && (offset < 0 || token.offset < offset)) { | 366 if (token != null && (offset < 0 || token.offset < offset)) { |
| 365 first = token; | 367 first = token; |
| 366 offset = token.offset; | 368 offset = token.offset; |
| 367 } | 369 } |
| 368 } | 370 } |
| 369 return first; | 371 return first; |
| 370 } | 372 } |
| 371 } | 373 } |
| 372 | 374 |
| 373 /** | 375 /** |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 */ | 736 */ |
| 735 class _EndOfFileTokenType extends TokenType { | 737 class _EndOfFileTokenType extends TokenType { |
| 736 /** | 738 /** |
| 737 * Initialize a newly created token. | 739 * Initialize a newly created token. |
| 738 */ | 740 */ |
| 739 const _EndOfFileTokenType() : super._('EOF', TokenClass.NO_CLASS, ''); | 741 const _EndOfFileTokenType() : super._('EOF', TokenClass.NO_CLASS, ''); |
| 740 | 742 |
| 741 @override | 743 @override |
| 742 String toString() => '-eof-'; | 744 String toString() => '-eof-'; |
| 743 } | 745 } |
| OLD | NEW |