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

Unified Diff: pkg/front_end/lib/src/scanner/token.dart

Issue 2899043006: cleanup fasta token classes (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/scanner/token.dart
diff --git a/pkg/front_end/lib/src/scanner/token.dart b/pkg/front_end/lib/src/scanner/token.dart
index ec38b9ce0b59ba14ed871226fd850254c2450e29..c4ce6f1e55239614c0f56350ba96ea2f8e7fc2b3 100644
--- a/pkg/front_end/lib/src/scanner/token.dart
+++ b/pkg/front_end/lib/src/scanner/token.dart
@@ -45,7 +45,8 @@ class BeginToken extends SimpleToken {
* [offset].
*/
BeginToken(TokenType type, int offset) : super(type, offset) {
- assert(type == TokenType.OPEN_CURLY_BRACKET ||
+ assert(type == TokenType.LT ||
+ type == TokenType.OPEN_CURLY_BRACKET ||
type == TokenType.OPEN_PAREN ||
type == TokenType.OPEN_SQUARE_BRACKET ||
type == TokenType.STRING_INTERPOLATION_EXPRESSION);
@@ -53,6 +54,18 @@ class BeginToken extends SimpleToken {
@override
Token copy() => new BeginToken(type, offset);
+
+ /**
+ * The token that corresponds to this token.
+ */
+ Token get endGroup => endToken;
+
+ /**
+ * Set the token that corresponds to this token.
+ */
+ set endGroup(Token token) {
+ endToken = token;
+ }
}
/**
@@ -712,6 +725,22 @@ class SyntheticStringToken extends StringToken {
@override
bool get isSynthetic => true;
+
+ @override
+ Token copy() => new SyntheticStringToken(type, _value, offset);
+}
+
+/**
+ * A synthetic token.
+ */
+class SyntheticToken extends SimpleToken {
+ SyntheticToken(TokenType type, int offset) : super(type, offset);
+
+ @override
+ int get length => 0;
+
+ @override
+ Token copy() => new SyntheticToken(type, offset);
}
/**
@@ -727,6 +756,19 @@ abstract class Token implements SyntacticEntity {
factory Token(TokenType type, int offset) = SimpleToken;
/**
+ * Initialize a newly created end-of-file token to have the given [offset].
+ */
+ factory Token.eof(int offset, [CommentToken precedingComments]) {
+ Token eof = precedingComments == null
+ ? new SimpleToken(TokenType.EOF, offset)
+ : new TokenWithComment(TokenType.EOF, offset, precedingComments);
+ // EOF points to itself so there's always infinite look-ahead.
+ eof.previous = eof;
+ eof.next = eof;
+ return eof;
+ }
+
+ /**
* The number of characters parsed by this token.
*/
int get charCount;
« no previous file with comments | « pkg/front_end/lib/src/scanner/scanner.dart ('k') | pkg/front_end/test/fasta/parser/token_stream_rewriter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698