Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: pkg/front_end/lib/src/scanner/token.dart

Issue 2794653002: fasta tokens implement analyzer token API (Closed)
Patch Set: merge Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/front_end/lib/src/scanner/scanner.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/scanner/scanner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698