OLD | NEW |
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 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 */ | 2792 */ |
2793 FormalParameter parseFormalParameter(ParameterKind kind) { | 2793 FormalParameter parseFormalParameter(ParameterKind kind) { |
2794 NormalFormalParameter parameter = parseNormalFormalParameter(); | 2794 NormalFormalParameter parameter = parseNormalFormalParameter(); |
2795 TokenType type = _currentToken.type; | 2795 TokenType type = _currentToken.type; |
2796 if (type == TokenType.EQ) { | 2796 if (type == TokenType.EQ) { |
2797 Token separator = getAndAdvance(); | 2797 Token separator = getAndAdvance(); |
2798 Expression defaultValue = parseExpression2(); | 2798 Expression defaultValue = parseExpression2(); |
2799 if (kind == ParameterKind.REQUIRED) { | 2799 if (kind == ParameterKind.REQUIRED) { |
2800 _reportErrorForNode( | 2800 _reportErrorForNode( |
2801 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parameter); | 2801 ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parameter); |
| 2802 kind = ParameterKind.POSITIONAL; |
2802 } | 2803 } |
2803 return new DefaultFormalParameter( | 2804 return new DefaultFormalParameter( |
2804 parameter, kind, separator, defaultValue); | 2805 parameter, kind, separator, defaultValue); |
2805 } else if (type == TokenType.COLON) { | 2806 } else if (type == TokenType.COLON) { |
2806 Token separator = getAndAdvance(); | 2807 Token separator = getAndAdvance(); |
2807 Expression defaultValue = parseExpression2(); | 2808 Expression defaultValue = parseExpression2(); |
2808 if (kind == ParameterKind.POSITIONAL) { | 2809 if (kind == ParameterKind.POSITIONAL) { |
2809 _reportErrorForToken( | 2810 _reportErrorForToken( |
2810 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, | 2811 ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, |
2811 separator); | 2812 separator); |
2812 } else if (kind == ParameterKind.REQUIRED) { | 2813 } else if (kind == ParameterKind.REQUIRED) { |
2813 _reportErrorForNode( | 2814 _reportErrorForNode( |
2814 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter); | 2815 ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter); |
| 2816 kind = ParameterKind.NAMED; |
2815 } | 2817 } |
2816 return new DefaultFormalParameter( | 2818 return new DefaultFormalParameter( |
2817 parameter, kind, separator, defaultValue); | 2819 parameter, kind, separator, defaultValue); |
2818 } else if (kind != ParameterKind.REQUIRED) { | 2820 } else if (kind != ParameterKind.REQUIRED) { |
2819 return new DefaultFormalParameter(parameter, kind, null, null); | 2821 return new DefaultFormalParameter(parameter, kind, null, null); |
2820 } | 2822 } |
2821 return parameter; | 2823 return parameter; |
2822 } | 2824 } |
2823 | 2825 |
2824 /** | 2826 /** |
(...skipping 5295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8120 */ | 8122 */ |
8121 Parser_SyntheticKeywordToken(Keyword keyword, int offset) | 8123 Parser_SyntheticKeywordToken(Keyword keyword, int offset) |
8122 : super(keyword, offset); | 8124 : super(keyword, offset); |
8123 | 8125 |
8124 @override | 8126 @override |
8125 int get length => 0; | 8127 int get length => 0; |
8126 | 8128 |
8127 @override | 8129 @override |
8128 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); | 8130 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); |
8129 } | 8131 } |
OLD | NEW |