| Index: pkg/front_end/lib/src/fasta/parser/parser.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart
|
| index 02bee28ffd2e7a27d90d854c873a7754b8e2dd98..dd76274961cc3f9c754b1b57ed5a99f9d4fa0f15 100644
|
| --- a/pkg/front_end/lib/src/fasta/parser/parser.dart
|
| +++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
|
| @@ -77,6 +77,7 @@ import '../../scanner/token.dart'
|
| EQUALITY_PRECEDENCE,
|
| POSTFIX_PRECEDENCE,
|
| RELATIONAL_PRECEDENCE,
|
| + SyntheticStringToken,
|
| TokenType;
|
|
|
| import '../scanner/token.dart' show isUserDefinableOperator;
|
| @@ -114,6 +115,7 @@ import 'async_modifier.dart' show AsyncModifier;
|
| import 'listener.dart' show Listener;
|
|
|
| import 'identifier_context.dart' show IdentifierContext;
|
| +import 'package:front_end/src/fasta/parser/token_stream_rewriter.dart';
|
|
|
| /// Returns true if [token] is the symbol or keyword [value].
|
| bool optional(String value, Token token) {
|
| @@ -310,6 +312,8 @@ class Parser {
|
|
|
| bool mayParseFunctionExpressions = true;
|
|
|
| + TokenStreamRewriter _rewriter;
|
| +
|
| /// Represents parser state: what asynchronous syntax is allowed in the
|
| /// function being currently parsed. In rare situations, this can be set by
|
| /// external clients, for example, to parse an expression outside a function.
|
| @@ -330,6 +334,7 @@ class Parser {
|
| bool get inPlainSync => asyncState == AsyncModifier.Sync;
|
|
|
| Token parseUnit(Token token) {
|
| + _rewriter = new TokenStreamRewriter(token);
|
| listener.beginCompilationUnit(token);
|
| int count = 0;
|
| while (!identical(token.kind, EOF_TOKEN)) {
|
| @@ -459,7 +464,7 @@ class Parser {
|
| Token exportKeyword = token;
|
| listener.beginExport(exportKeyword);
|
| assert(optional('export', token));
|
| - token = parseLiteralStringOrRecoverExpression(token.next);
|
| + token = parseLiteralString(ensureLiteralString(token.next));
|
| token = parseConditionalUris(token);
|
| token = parseCombinators(token);
|
| Token semicolon = token;
|
| @@ -1085,6 +1090,17 @@ class Parser {
|
| return token.next;
|
| }
|
|
|
| + Token ensureLiteralString(Token token) {
|
| + if (!identical(token.kind, STRING_TOKEN)) {
|
| + print('>>> ensureLiteralString');
|
| + reportRecoverableErrorCodeWithToken(token, codeExpectedString);
|
| + token = _rewriter.insertTokenBefore(
|
| + new SyntheticStringToken(TokenType.STRING, '""', token.offset, 0),
|
| + token);
|
| + }
|
| + return token;
|
| + }
|
| +
|
| Token expect(String string, Token token) {
|
| if (!identical(string, token.stringValue)) {
|
| return reportUnrecoverableErrorCodeWithString(
|
|
|