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