| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 | 10 |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 token = token.next; | 593 token = token.next; |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 @override | 597 @override |
| 598 Token copy() => new StringTokenWithComment( | 598 Token copy() => new StringTokenWithComment( |
| 599 type, lexeme, offset, copyComments(precedingComments)); | 599 type, lexeme, offset, copyComments(precedingComments)); |
| 600 } | 600 } |
| 601 | 601 |
| 602 /** | 602 /** |
| 603 * A synthetic keyword token. |
| 604 */ |
| 605 class SyntheticKeywordToken extends KeywordToken { |
| 606 /** |
| 607 * Initialize a newly created token to represent the given [keyword] at the |
| 608 * given [offset]. |
| 609 */ |
| 610 SyntheticKeywordToken(Keyword keyword, int offset) : super(keyword, offset); |
| 611 |
| 612 @override |
| 613 int get length => 0; |
| 614 |
| 615 @override |
| 616 Token copy() => new SyntheticKeywordToken(keyword, offset); |
| 617 } |
| 618 |
| 619 /** |
| 620 * A token whose value is independent of it's type. |
| 621 */ |
| 622 class SyntheticStringToken extends StringToken { |
| 623 /** |
| 624 * Initialize a newly created token to represent a token of the given [type] |
| 625 * with the given [value] at the given [offset]. |
| 626 */ |
| 627 SyntheticStringToken(TokenType type, String value, int offset) |
| 628 : super(type, value, offset); |
| 629 |
| 630 @override |
| 631 bool get isSynthetic => true; |
| 632 } |
| 633 |
| 634 /** |
| 603 * A token that was scanned from the input. Each token knows which tokens | 635 * A token that was scanned from the input. Each token knows which tokens |
| 604 * precede and follow it, acting as a link in a doubly linked list of tokens. | 636 * precede and follow it, acting as a link in a doubly linked list of tokens. |
| 605 * | 637 * |
| 606 * Clients may not extend, implement or mix-in this class. | 638 * Clients may not extend, implement or mix-in this class. |
| 607 */ | 639 */ |
| 608 abstract class Token implements SyntacticEntity { | 640 abstract class Token implements SyntacticEntity { |
| 609 /** | 641 /** |
| 610 * Initialize a newly created token to have the given [type] and [offset]. | 642 * Initialize a newly created token to have the given [type] and [offset]. |
| 611 */ | 643 */ |
| 612 factory Token(TokenType type, int offset) = SimpleToken; | 644 factory Token(TokenType type, int offset) = SimpleToken; |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 | 1188 |
| 1157 void set precedingComments(CommentToken comment) { | 1189 void set precedingComments(CommentToken comment) { |
| 1158 _precedingComment = comment; | 1190 _precedingComment = comment; |
| 1159 _setCommentParent(_precedingComment); | 1191 _setCommentParent(_precedingComment); |
| 1160 } | 1192 } |
| 1161 | 1193 |
| 1162 @override | 1194 @override |
| 1163 Token copy() => | 1195 Token copy() => |
| 1164 new TokenWithComment(type, offset, copyComments(precedingComments)); | 1196 new TokenWithComment(type, offset, copyComments(precedingComments)); |
| 1165 } | 1197 } |
| OLD | NEW |