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

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

Issue 2759643002: Use identical or optional for keywords. (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 | « no previous file | no next file » | 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 9afefb73b9fcf3f10259c3e768bccc499db29185..1650fd13741f968bf9c9dcf4490551b62159aa60 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -2694,23 +2694,23 @@ class Parser {
} else if (kind == HASH_TOKEN) {
return parseLiteralSymbol(token);
} else if (kind == KEYWORD_TOKEN) {
- final value = token.stringValue;
- if (value == 'true' || value == 'false') {
+ final String value = token.stringValue;
+ if (identical(value, "true") || identical(value, "false")) {
return parseLiteralBool(token);
- } else if (value == 'null') {
+ } else if (identical(value, "null")) {
return parseLiteralNull(token);
- } else if (value == 'this') {
+ } else if (identical(value, "this")) {
return parseThisExpression(token);
- } else if (value == 'super') {
+ } else if (identical(value, "super")) {
return parseSuperExpression(token);
- } else if (value == 'new') {
+ } else if (identical(value, "new")) {
return parseNewExpression(token);
- } else if (value == 'const') {
+ } else if (identical(value, "const")) {
return parseConstExpression(token);
- } else if (value == 'void') {
+ } else if (identical(value, "void")) {
return parseFunctionExpression(token);
} else if (asyncState != AsyncModifier.Sync &&
- (value == 'yield' || value == 'async')) {
+ (identical(value, "yield") || identical(value, "async"))) {
return expressionExpected(token);
} else if (token.isIdentifier()) {
return parseSendOrFunctionLiteral(token);
@@ -2719,7 +2719,7 @@ class Parser {
}
} else if (kind == OPEN_PAREN_TOKEN) {
return parseParenthesizedExpressionOrFunctionLiteral(token);
- } else if (kind == OPEN_SQUARE_BRACKET_TOKEN || token.stringValue == '[]') {
+ } else if (kind == OPEN_SQUARE_BRACKET_TOKEN || optional('[]', token)) {
Johnni Winther 2017/03/17 12:03:52 Why use `optional`? Is it faster? (It doesn't read
ahe 2017/03/17 13:48:27 For consistency, I prefer to use "optional" unless
listener.handleNoTypeArguments(token);
return parseLiteralListSuffix(token, null);
} else if (kind == OPEN_CURLY_BRACKET_TOKEN) {
@@ -2747,7 +2747,8 @@ class Parser {
(identical(kind, FUNCTION_TOKEN) ||
identical(kind, OPEN_CURLY_BRACKET_TOKEN) ||
(identical(kind, KEYWORD_TOKEN) &&
- (nextToken.lexeme == 'async' || nextToken.lexeme == 'sync')))) {
+ (optional('async', nextToken) ||
+ optional('sync', nextToken))))) {
listener.handleNoTypeVariables(token);
return parseUnnamedFunction(token);
} else {
@@ -2866,7 +2867,7 @@ class Parser {
if (identical(kind, FUNCTION_TOKEN) ||
identical(kind, OPEN_CURLY_BRACKET_TOKEN) ||
(identical(kind, KEYWORD_TOKEN) &&
- (nextToken.lexeme == 'async' || nextToken.lexeme == 'sync'))) {
+ (optional('async', nextToken) || optional('sync', nextToken)))) {
return parseUnnamedFunction(token);
}
// Fall through.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698