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

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

Issue 2777153002: move synthetic fasta closers into the token stream (Closed)
Patch Set: rebase Created 3 years, 9 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/fasta/scanner/token.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/token.dart b/pkg/front_end/lib/src/fasta/scanner/token.dart
index 467f55d36447631e9835a61714e8a4edaebde9f1..d72cf9b9daab1e179de45f5890f2390d070fafbd 100644
--- a/pkg/front_end/lib/src/fasta/scanner/token.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/token.dart
@@ -215,7 +215,7 @@ abstract class Token implements analyzer.TokenWithComment {
Token copyWithoutComments();
@override
- bool get isSynthetic => charCount == 0;
+ bool get isSynthetic => false;
@override
analyzer.Keyword get keyword => null;
@@ -256,12 +256,12 @@ class SymbolToken extends Token {
SymbolToken(this.info, int charOffset) : super(charOffset);
- SymbolToken.eof(int charOffset)
- : info = EOF_INFO,
- super(charOffset) {
+ factory SymbolToken.eof(int charOffset) {
+ var eof = new SyntheticSymbolToken(EOF_INFO, charOffset);
// EOF points to itself so there's always infinite look-ahead.
- previousToken = this;
- next = this;
+ eof.previousToken = eof;
+ eof.next = eof;
+ return eof;
}
String get lexeme => info.value;
@@ -279,6 +279,23 @@ class SymbolToken extends Token {
}
/**
+ * A [SyntheticSymbolToken] represents the symbol in its precedence info
+ * which does not exist in the original source.
+ * For example, if the scanner finds '(' missing a ')'
+ * then it will insert an synthetic ')'.
+ */
+class SyntheticSymbolToken extends SymbolToken {
+ SyntheticSymbolToken(PrecedenceInfo info, int charOffset)
+ : super(info, charOffset);
+
+ @override
+ int get charCount => 0;
+
+ @override
+ bool get isSynthetic => true;
+}
+
+/**
* A [BeginGroupToken] represents a symbol that may be the beginning of
* a pair of brackets, i.e., ( { [ < or ${
* The [endGroup] token points to the matching closing bracked in case
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart ('k') | pkg/front_end/test/scanner_fasta_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698