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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 first = token; | 360 first = token; |
361 offset = token.offset; | 361 offset = token.offset; |
362 } | 362 } |
363 } | 363 } |
364 return first; | 364 return first; |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 /** | 368 /** |
369 * The types of tokens that can be returned by the scanner. | 369 * The types of tokens that can be returned by the scanner. |
| 370 * |
| 371 * Clients may not extend, implement or mix-in this class. |
370 */ | 372 */ |
371 class TokenType { | 373 class TokenType { |
372 /** | 374 /** |
373 * The type of the token that marks the end of the input. | 375 * The type of the token that marks the start or end of the input. |
374 */ | 376 */ |
375 static const TokenType EOF = const _EndOfFileTokenType(); | 377 static const TokenType EOF = const _EndOfFileTokenType(); |
376 | 378 |
377 static const TokenType DOUBLE = const TokenType._('DOUBLE'); | 379 static const TokenType DOUBLE = const TokenType._('DOUBLE'); |
378 | 380 |
379 static const TokenType HEXADECIMAL = const TokenType._('HEXADECIMAL'); | 381 static const TokenType HEXADECIMAL = const TokenType._('HEXADECIMAL'); |
380 | 382 |
381 static const TokenType IDENTIFIER = const TokenType._('IDENTIFIER'); | 383 static const TokenType IDENTIFIER = const TokenType._('IDENTIFIER'); |
382 | 384 |
383 static const TokenType INT = const TokenType._('INT'); | 385 static const TokenType INT = const TokenType._('INT'); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 * The name of the token type. | 593 * The name of the token type. |
592 */ | 594 */ |
593 final String name; | 595 final String name; |
594 | 596 |
595 /** | 597 /** |
596 * The lexeme that defines this type of token, or `null` if there is more than | 598 * The lexeme that defines this type of token, or `null` if there is more than |
597 * one possible lexeme for this type of token. | 599 * one possible lexeme for this type of token. |
598 */ | 600 */ |
599 final String lexeme; | 601 final String lexeme; |
600 | 602 |
| 603 /** |
| 604 * Initialize a newly created token type to have the given [name], |
| 605 * [_tokenClass] and [lexeme]. |
| 606 */ |
601 const TokenType._(this.name, | 607 const TokenType._(this.name, |
602 [this._tokenClass = TokenClass.NO_CLASS, this.lexeme = null]); | 608 [this._tokenClass = TokenClass.NO_CLASS, this.lexeme = null]); |
603 | 609 |
604 /** | 610 /** |
605 * Return `true` if this type of token represents an additive operator. | 611 * Return `true` if this type of token represents an additive operator. |
606 */ | 612 */ |
607 bool get isAdditiveOperator => _tokenClass == TokenClass.ADDITIVE_OPERATOR; | 613 bool get isAdditiveOperator => _tokenClass == TokenClass.ADDITIVE_OPERATOR; |
608 | 614 |
609 /** | 615 /** |
610 * Return `true` if this type of token represents an assignment operator. | 616 * Return `true` if this type of token represents an assignment operator. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 */ | 729 */ |
724 class _EndOfFileTokenType extends TokenType { | 730 class _EndOfFileTokenType extends TokenType { |
725 /** | 731 /** |
726 * Initialize a newly created token. | 732 * Initialize a newly created token. |
727 */ | 733 */ |
728 const _EndOfFileTokenType() : super._('EOF', TokenClass.NO_CLASS, ''); | 734 const _EndOfFileTokenType() : super._('EOF', TokenClass.NO_CLASS, ''); |
729 | 735 |
730 @override | 736 @override |
731 String toString() => '-eof-'; | 737 String toString() => '-eof-'; |
732 } | 738 } |
OLD | NEW |