| 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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 int get length => 0; | 709 int get length => 0; |
| 710 | 710 |
| 711 @override | 711 @override |
| 712 Token copy() => new SyntheticKeywordToken(keyword, offset); | 712 Token copy() => new SyntheticKeywordToken(keyword, offset); |
| 713 } | 713 } |
| 714 | 714 |
| 715 /** | 715 /** |
| 716 * A token whose value is independent of it's type. | 716 * A token whose value is independent of it's type. |
| 717 */ | 717 */ |
| 718 class SyntheticStringToken extends StringToken { | 718 class SyntheticStringToken extends StringToken { |
| 719 final int _length; | |
| 720 | |
| 721 /** | 719 /** |
| 722 * Initialize a newly created token to represent a token of the given [type] | 720 * Initialize a newly created token to represent a token of the given [type] |
| 723 * with the given [value] at the given [offset]. If the [length] is | 721 * with the given [value] at the given [offset]. |
| 724 * not specified, then it defaults to the length of [value]. | |
| 725 */ | 722 */ |
| 726 SyntheticStringToken(TokenType type, String value, int offset, [this._length]) | 723 SyntheticStringToken(TokenType type, String value, int offset) |
| 727 : super(type, value, offset); | 724 : super(type, value, offset); |
| 728 | 725 |
| 729 @override | 726 @override |
| 730 bool get isSynthetic => true; | 727 bool get isSynthetic => true; |
| 731 | 728 |
| 732 @override | 729 @override |
| 733 int get length => _length ?? super.length; | |
| 734 | |
| 735 @override | |
| 736 Token copy() => new SyntheticStringToken(type, _value, offset); | 730 Token copy() => new SyntheticStringToken(type, _value, offset); |
| 737 } | 731 } |
| 738 | 732 |
| 739 /** | 733 /** |
| 740 * A synthetic token. | 734 * A synthetic token. |
| 741 */ | 735 */ |
| 742 class SyntheticToken extends SimpleToken { | 736 class SyntheticToken extends SimpleToken { |
| 743 SyntheticToken(TokenType type, int offset) : super(type, offset); | 737 SyntheticToken(TokenType type, int offset) : super(type, offset); |
| 744 | 738 |
| 745 @override | 739 @override |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 | 1680 |
| 1687 void set precedingComments(CommentToken comment) { | 1681 void set precedingComments(CommentToken comment) { |
| 1688 _precedingComment = comment; | 1682 _precedingComment = comment; |
| 1689 _setCommentParent(_precedingComment); | 1683 _setCommentParent(_precedingComment); |
| 1690 } | 1684 } |
| 1691 | 1685 |
| 1692 @override | 1686 @override |
| 1693 Token copy() => | 1687 Token copy() => |
| 1694 new TokenWithComment(type, offset, copyComments(precedingComments)); | 1688 new TokenWithComment(type, offset, copyComments(precedingComments)); |
| 1695 } | 1689 } |
| OLD | NEW |