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

Side by Side Diff: pkg/analyzer/lib/src/generated/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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.generated.parser; 5 library analyzer.src.generated.parser;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 2762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 /** 2773 /**
2774 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be 2774 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be
2775 * `true`. The [kind] is the kind of parameter being expected based on the 2775 * `true`. The [kind] is the kind of parameter being expected based on the
2776 * presence or absence of group delimiters. Return the formal parameter that 2776 * presence or absence of group delimiters. Return the formal parameter that
2777 * was parsed. 2777 * was parsed.
2778 * 2778 *
2779 * defaultFormalParameter ::= 2779 * defaultFormalParameter ::=
2780 * normalFormalParameter ('=' expression)? 2780 * normalFormalParameter ('=' expression)?
2781 * 2781 *
2782 * defaultNamedParameter ::= 2782 * defaultNamedParameter ::=
2783 * normalFormalParameter ('=' expression)?
2783 * normalFormalParameter (':' expression)? 2784 * normalFormalParameter (':' expression)?
2784 */ 2785 */
2785 FormalParameter parseFormalParameter(ParameterKind kind) { 2786 FormalParameter parseFormalParameter(ParameterKind kind) {
2786 NormalFormalParameter parameter = parseNormalFormalParameter(); 2787 NormalFormalParameter parameter = parseNormalFormalParameter();
2787 TokenType type = _currentToken.type; 2788 TokenType type = _currentToken.type;
2788 if (type == TokenType.EQ) { 2789 if (type == TokenType.EQ) {
2789 Token separator = getAndAdvance(); 2790 Token separator = getAndAdvance();
2790 Expression defaultValue = parseExpression2(); 2791 Expression defaultValue = parseExpression2();
2791 if (kind == ParameterKind.NAMED) { 2792 if (kind == ParameterKind.REQUIRED) {
2792 _reportErrorForToken(
2793 ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, separator);
floitsch 2016/10/11 09:37:11 Remove error message.
Lasse Reichstein Nielsen 2016/10/11 13:35:18 Done.
2794 } else if (kind == ParameterKind.REQUIRED) {
2795 _reportErrorForNode( 2793 _reportErrorForNode(
2796 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parameter); 2794 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parameter);
2797 } 2795 }
2798 return new DefaultFormalParameter( 2796 return new DefaultFormalParameter(
2799 parameter, kind, separator, defaultValue); 2797 parameter, kind, separator, defaultValue);
2800 } else if (type == TokenType.COLON) { 2798 } else if (type == TokenType.COLON) {
2801 Token separator = getAndAdvance(); 2799 Token separator = getAndAdvance();
2802 Expression defaultValue = parseExpression2(); 2800 Expression defaultValue = parseExpression2();
2803 if (kind == ParameterKind.POSITIONAL) { 2801 if (kind == ParameterKind.POSITIONAL) {
2804 _reportErrorForToken( 2802 _reportErrorForToken(
(...skipping 5294 matching lines...) Expand 10 before | Expand all | Expand 10 after
8099 */ 8097 */
8100 Parser_SyntheticKeywordToken(Keyword keyword, int offset) 8098 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
8101 : super(keyword, offset); 8099 : super(keyword, offset);
8102 8100
8103 @override 8101 @override
8104 int get length => 0; 8102 int get length => 0;
8105 8103
8106 @override 8104 @override
8107 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); 8105 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
8108 } 8106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698