| Index: pkg/front_end/lib/src/fasta/parser/listener.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/parser/listener.dart b/pkg/front_end/lib/src/fasta/parser/listener.dart
|
| index cf593707ba667256f50549309facba3f41fc13df..bec0c9ad2a4bf88be9f3f0fa8b757b418d227259 100644
|
| --- a/pkg/front_end/lib/src/fasta/parser/listener.dart
|
| +++ b/pkg/front_end/lib/src/fasta/parser/listener.dart
|
| @@ -20,6 +20,8 @@ import 'member_kind.dart' show MemberKind;
|
|
|
| import 'parser_error.dart' show ParserError;
|
|
|
| +import 'token_stream_rewriter.dart';
|
| +
|
| /// A parser event listener that does nothing except throw exceptions
|
| /// on parser errors.
|
| ///
|
| @@ -34,6 +36,23 @@ import 'parser_error.dart' show ParserError;
|
| class Listener {
|
| final List<ParserError> recoverableErrors = <ParserError>[];
|
|
|
| + /// The first token in the parse stream and used during parser recovery.
|
| + /// This is automatically set by the [beginCompilationUnit] event,
|
| + /// but must be manually set when parsing anything smaller.
|
| + Token firstToken;
|
| +
|
| + /// A rewriter for inserting synthetic tokens.
|
| + /// Access using [rewriter] for lazy initialization.
|
| + TokenStreamRewriter _tokenRewriter;
|
| +
|
| + TokenStreamRewriter get rewriter {
|
| + assert(firstToken != null, 'firstToken must be set for parser recovery');
|
| + _tokenRewriter ??= new TokenStreamRewriter(firstToken);
|
| + return _tokenRewriter;
|
| + }
|
| +
|
| + Listener();
|
| +
|
| Uri get uri => null;
|
|
|
| void logEvent(String name) {}
|
| @@ -112,7 +131,9 @@ class Listener {
|
| logEvent("Combinators");
|
| }
|
|
|
| - void beginCompilationUnit(Token token) {}
|
| + void beginCompilationUnit(Token token) {
|
| + firstToken = token;
|
| + }
|
|
|
| void endCompilationUnit(int count, Token token) {
|
| logEvent("CompilationUnit");
|
|
|