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

Unified Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2768523002: Fix IdentifierContext for primary expressions. Also pass IdentifierContext to handleThisExpression … (Closed)
Patch Set: 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/listener.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 149b86c599880b840fa52a95003d254246d53757..516ad61e9024d34db655c7895af28e80a9be0489 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -2598,7 +2598,8 @@ class Parser {
// should just call [parseUnaryExpression] directly. However, a
// unary expression isn't legal after a period, so we call
// [parsePrimary] instead.
- token = parsePrimary(token.next);
+ token = parsePrimary(
+ token.next, IdentifierContext.expressionContinuation);
listener.handleBinaryExpression(operator);
} else if ((identical(info, OPEN_PAREN_INFO)) ||
(identical(info, OPEN_SQUARE_BRACKET_INFO))) {
@@ -2676,7 +2677,7 @@ class Parser {
// Prefix:
if (optional('await', token)) {
if (inPlainSync) {
- return parsePrimary(token);
+ return parsePrimary(token, IdentifierContext.expression);
} else {
return parseAwaitExpression(token, allowCascades);
}
@@ -2704,7 +2705,7 @@ class Parser {
listener.handleUnaryPrefixAssignmentExpression(operator);
return token;
} else {
- return parsePrimary(token);
+ return parsePrimary(token, IdentifierContext.expression);
}
}
@@ -2730,10 +2731,10 @@ class Parser {
return token;
}
- Token parsePrimary(Token token) {
+ Token parsePrimary(Token token, IdentifierContext context) {
final kind = token.kind;
if (kind == IDENTIFIER_TOKEN) {
- return parseSendOrFunctionLiteral(token);
+ return parseSendOrFunctionLiteral(token, context);
} else if (kind == INT_TOKEN || kind == HEXADECIMAL_TOKEN) {
return parseLiteralInt(token);
} else if (kind == DOUBLE_TOKEN) {
@@ -2749,9 +2750,9 @@ class Parser {
} else if (identical(value, "null")) {
return parseLiteralNull(token);
} else if (identical(value, "this")) {
- return parseThisExpression(token);
+ return parseThisExpression(token, context);
} else if (identical(value, "super")) {
- return parseSuperExpression(token);
+ return parseSuperExpression(token, context);
} else if (identical(value, "new")) {
return parseNewExpression(token);
} else if (identical(value, "const")) {
@@ -2762,7 +2763,7 @@ class Parser {
(identical(value, "yield") || identical(value, "async"))) {
return expressionExpected(token);
} else if (token.isIdentifier()) {
- return parseSendOrFunctionLiteral(token);
+ return parseSendOrFunctionLiteral(token, context);
} else {
return expressionExpected(token);
}
@@ -2824,9 +2825,9 @@ class Parser {
return expect(')', token);
}
- Token parseThisExpression(Token token) {
+ Token parseThisExpression(Token token, IdentifierContext context) {
Token beginToken = token;
- listener.handleThisExpression(token);
+ listener.handleThisExpression(token, context);
token = token.next;
if (optional('(', token)) {
// Constructor forwarding.
@@ -2837,9 +2838,9 @@ class Parser {
return token;
}
- Token parseSuperExpression(Token token) {
+ Token parseSuperExpression(Token token, IdentifierContext context) {
Token beginToken = token;
- listener.handleSuperExpression(token);
+ listener.handleSuperExpression(token, context);
token = token.next;
if (optional('(', token)) {
// Super constructor.
@@ -2965,9 +2966,9 @@ class Parser {
return token;
}
- Token parseSendOrFunctionLiteral(Token token) {
+ Token parseSendOrFunctionLiteral(Token token, IdentifierContext context) {
if (!mayParseFunctionExpressions) {
- return parseSend(token, IdentifierContext.expression);
+ return parseSend(token, context);
}
Token peek = peekAfterIfType(token);
if (peek != null &&
@@ -2977,7 +2978,7 @@ class Parser {
} else if (isFunctionDeclaration(token.next)) {
return parseFunctionExpression(token);
} else {
- return parseSend(token, IdentifierContext.expression);
+ return parseSend(token, context);
}
}
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/listener.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698