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

Side by Side Diff: pkg/compiler/lib/src/parser/parser.dart

Issue 2411633002: Add `=` as default-value separator for named parameters. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.parser; 5 library dart2js.parser;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../options.dart' show ParserOptions; 8 import '../options.dart' show ParserOptions;
9 import '../tokens/keyword.dart' show Keyword; 9 import '../tokens/keyword.dart' show Keyword;
10 import '../tokens/precedence.dart' show PrecedenceInfo; 10 import '../tokens/precedence.dart' show PrecedenceInfo;
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 String value = token.stringValue; 474 String value = token.stringValue;
475 if ((identical('=', value)) || (identical(':', value))) { 475 if ((identical('=', value)) || (identical(':', value))) {
476 // TODO(ahe): Validate that these are only used for optional parameters. 476 // TODO(ahe): Validate that these are only used for optional parameters.
477 Token equal = token; 477 Token equal = token;
478 token = parseExpression(token.next); 478 token = parseExpression(token.next);
479 listener.handleValuedFormalParameter(equal, token); 479 listener.handleValuedFormalParameter(equal, token);
480 if (type.isRequired) { 480 if (type.isRequired) {
481 listener.reportError( 481 listener.reportError(
482 equal, MessageKind.REQUIRED_PARAMETER_WITH_DEFAULT); 482 equal, MessageKind.REQUIRED_PARAMETER_WITH_DEFAULT);
483 } else if (type.isNamed && identical('=', value)) {
484 listener.reportError(equal, MessageKind.NAMED_PARAMETER_WITH_EQUALS);
floitsch 2016/10/11 09:37:11 Remove that error message.
Lasse Reichstein Nielsen 2016/10/11 13:35:18 Done.
485 } else if (type.isPositional && identical(':', value)) { 483 } else if (type.isPositional && identical(':', value)) {
486 listener.reportError( 484 listener.reportError(
487 equal, MessageKind.POSITIONAL_PARAMETER_WITH_EQUALS); 485 equal, MessageKind.POSITIONAL_PARAMETER_WITH_EQUALS);
488 } 486 }
489 } 487 }
490 listener.endFormalParameter(thisKeyword); 488 listener.endFormalParameter(thisKeyword);
491 return token; 489 return token;
492 } 490 }
493 491
494 Token parseOptionalFormalParameters(Token token, bool isNamed) { 492 Token parseOptionalFormalParameters(Token token, bool isNamed) {
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after
3007 } 3005 }
3008 listener.handleContinueStatement(hasTarget, continueKeyword, token); 3006 listener.handleContinueStatement(hasTarget, continueKeyword, token);
3009 return expectSemicolon(token); 3007 return expectSemicolon(token);
3010 } 3008 }
3011 3009
3012 Token parseEmptyStatement(Token token) { 3010 Token parseEmptyStatement(Token token) {
3013 listener.handleEmptyStatement(token); 3011 listener.handleEmptyStatement(token);
3014 return expectSemicolon(token); 3012 return expectSemicolon(token);
3015 } 3013 }
3016 } 3014 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698