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

Unified Diff: runtime/vm/parser.cc

Issue 1991043004: Allow trailing comma in parameter and argument lists. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 7819cd780ac26f66bf7a1621d56cd8d5c8611bac..d4b3e6943137328308dceb84aec9ec922b3a9157 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -2031,6 +2031,14 @@ void Parser::ParseFormalParameters(bool allow_explicit_default_values,
params->has_optional_named_parameters = true;
return;
}
+ Token::Kind terminator =
+ params->has_optional_positional_parameters ? Token::kRBRACK :
+ params->has_optional_named_parameters ? Token::kRBRACE :
+ Token :: kRPAREN;
+ if (CurrentToken() == terminator) {
hausner 2016/06/22 17:50:25 You are allowing an empty list of optional positio
Lasse Reichstein Nielsen 2016/06/24 11:43:04 Good point. Curiously, it's only an empty named b
+ // Allow a trailing comma.
+ break;
+ }
ParseFormalParameter(allow_explicit_default_values,
evaluate_metadata,
params);
@@ -11125,6 +11133,10 @@ ArgumentListNode* Parser::ParseActualParameters(
ASSERT((CurrentToken() == Token::kLPAREN) ||
(CurrentToken() == Token::kCOMMA));
ConsumeToken();
+ if (CurrentToken() == Token::kRPAREN) {
+ // Allow trailing comma.
+ break;
+ }
if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) {
named_argument_seen = true;
// The canonicalization of the arguments descriptor array built in
« 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