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 |