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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 2630573002: Revert to old syntax to fix bots (TBR) (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 * The [optional] is `true` if the keyword and type are optional. Return the 2748 * The [optional] is `true` if the keyword and type are optional. Return the
2749 * 'final', 'const', 'var' or type that was parsed. 2749 * 'final', 'const', 'var' or type that was parsed.
2750 * 2750 *
2751 * finalConstVarOrType ::= 2751 * finalConstVarOrType ::=
2752 * 'final' type? 2752 * 'final' type?
2753 * | 'const' type? 2753 * | 'const' type?
2754 * | 'var' 2754 * | 'var'
2755 * | type 2755 * | type
2756 */ 2756 */
2757 FinalConstVarOrType parseFinalConstVarOrType(bool optional, 2757 FinalConstVarOrType parseFinalConstVarOrType(bool optional,
2758 {bool inFunctionType = false}) { 2758 {bool inFunctionType: false}) {
2759 Token keywordToken = null; 2759 Token keywordToken = null;
2760 TypeName type = null; 2760 TypeName type = null;
2761 Keyword keyword = _currentToken.keyword; 2761 Keyword keyword = _currentToken.keyword;
2762 if (keyword == Keyword.FINAL || keyword == Keyword.CONST) { 2762 if (keyword == Keyword.FINAL || keyword == Keyword.CONST) {
2763 keywordToken = getAndAdvance(); 2763 keywordToken = getAndAdvance();
2764 if (_isTypedIdentifier(_currentToken)) { 2764 if (_isTypedIdentifier(_currentToken)) {
2765 type = parseTypeName(false); 2765 type = parseTypeName(false);
2766 } else { 2766 } else {
2767 // Support `final/*=T*/ x;` 2767 // Support `final/*=T*/ x;`
2768 type = _parseOptionalTypeNameComment(); 2768 type = _parseOptionalTypeNameComment();
(...skipping 28 matching lines...) Expand all
2797 * was parsed. 2797 * was parsed.
2798 * 2798 *
2799 * defaultFormalParameter ::= 2799 * defaultFormalParameter ::=
2800 * normalFormalParameter ('=' expression)? 2800 * normalFormalParameter ('=' expression)?
2801 * 2801 *
2802 * defaultNamedParameter ::= 2802 * defaultNamedParameter ::=
2803 * normalFormalParameter ('=' expression)? 2803 * normalFormalParameter ('=' expression)?
2804 * normalFormalParameter (':' expression)? 2804 * normalFormalParameter (':' expression)?
2805 */ 2805 */
2806 FormalParameter parseFormalParameter(ParameterKind kind, 2806 FormalParameter parseFormalParameter(ParameterKind kind,
2807 {bool inFunctionType = false}) { 2807 {bool inFunctionType: false}) {
2808 NormalFormalParameter parameter = 2808 NormalFormalParameter parameter =
2809 parseNormalFormalParameter(inFunctionType: inFunctionType); 2809 parseNormalFormalParameter(inFunctionType: inFunctionType);
2810 TokenType type = _currentToken.type; 2810 TokenType type = _currentToken.type;
2811 if (type == TokenType.EQ) { 2811 if (type == TokenType.EQ) {
2812 if (inFunctionType) { 2812 if (inFunctionType) {
2813 _reportErrorForCurrentToken( 2813 _reportErrorForCurrentToken(
2814 ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE); 2814 ParserErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE);
2815 } 2815 }
2816 Token separator = getAndAdvance(); 2816 Token separator = getAndAdvance();
2817 Expression defaultValue = parseExpression2(); 2817 Expression defaultValue = parseExpression2();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2877 * optionalFormalParameters ::= 2877 * optionalFormalParameters ::=
2878 * optionalPositionalFormalParameters 2878 * optionalPositionalFormalParameters
2879 * | namedFormalParameters 2879 * | namedFormalParameters
2880 * 2880 *
2881 * optionalPositionalFormalParameters ::= 2881 * optionalPositionalFormalParameters ::=
2882 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' 2882 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']'
2883 * 2883 *
2884 * namedFormalParameters ::= 2884 * namedFormalParameters ::=
2885 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' 2885 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}'
2886 */ 2886 */
2887 FormalParameterList parseFormalParameterList({bool inFunctionType = false}) { 2887 FormalParameterList parseFormalParameterList({bool inFunctionType: false}) {
2888 if (_matches(TokenType.OPEN_PAREN)) { 2888 if (_matches(TokenType.OPEN_PAREN)) {
2889 return _parseFormalParameterListUnchecked(inFunctionType: inFunctionType); 2889 return _parseFormalParameterListUnchecked(inFunctionType: inFunctionType);
2890 } 2890 }
2891 // TODO(brianwilkerson) Improve the error message. 2891 // TODO(brianwilkerson) Improve the error message.
2892 _reportErrorForCurrentToken( 2892 _reportErrorForCurrentToken(
2893 ParserErrorCode.EXPECTED_TOKEN, [TokenType.OPEN_PAREN.lexeme]); 2893 ParserErrorCode.EXPECTED_TOKEN, [TokenType.OPEN_PAREN.lexeme]);
2894 // Recovery: Check for an unmatched closing paren and parse parameters until 2894 // Recovery: Check for an unmatched closing paren and parse parameters until
2895 // it is reached. 2895 // it is reached.
2896 return _parseFormalParameterListAfterParen( 2896 return _parseFormalParameterListAfterParen(
2897 _createSyntheticToken(TokenType.OPEN_PAREN)); 2897 _createSyntheticToken(TokenType.OPEN_PAREN));
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
4096 * metadata returnType? identifier typeParameters? formalParameterList 4096 * metadata returnType? identifier typeParameters? formalParameterList
4097 * 4097 *
4098 * fieldFormalParameter ::= 4098 * fieldFormalParameter ::=
4099 * metadata finalConstVarOrType? 'this' '.' identifier 4099 * metadata finalConstVarOrType? 'this' '.' identifier
4100 * 4100 *
4101 * simpleFormalParameter ::= 4101 * simpleFormalParameter ::=
4102 * declaredIdentifier 4102 * declaredIdentifier
4103 * | metadata identifier 4103 * | metadata identifier
4104 */ 4104 */
4105 NormalFormalParameter parseNormalFormalParameter( 4105 NormalFormalParameter parseNormalFormalParameter(
4106 {bool inFunctionType = false}) { 4106 {bool inFunctionType: false}) {
4107 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 4107 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
4108 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType, 4108 FinalConstVarOrType holder = parseFinalConstVarOrType(!inFunctionType,
4109 inFunctionType: inFunctionType); 4109 inFunctionType: inFunctionType);
4110 Token thisKeyword = null; 4110 Token thisKeyword = null;
4111 Token period = null; 4111 Token period = null;
4112 if (_matchesKeyword(Keyword.THIS)) { 4112 if (_matchesKeyword(Keyword.THIS)) {
4113 thisKeyword = getAndAdvance(); 4113 thisKeyword = getAndAdvance();
4114 period = _expect(TokenType.PERIOD); 4114 period = _expect(TokenType.PERIOD);
4115 } 4115 }
4116 if (!_matchesIdentifier() && inFunctionType) { 4116 if (!_matchesIdentifier() && inFunctionType) {
(...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after
6463 } 6463 }
6464 return astFactory.enumConstantDeclaration( 6464 return astFactory.enumConstantDeclaration(
6465 commentAndMetadata.comment, commentAndMetadata.metadata, name); 6465 commentAndMetadata.comment, commentAndMetadata.metadata, name);
6466 } 6466 }
6467 6467
6468 /** 6468 /**
6469 * Parse a list of formal parameters given that the list starts with the given 6469 * Parse a list of formal parameters given that the list starts with the given
6470 * [leftParenthesis]. Return the formal parameters that were parsed. 6470 * [leftParenthesis]. Return the formal parameters that were parsed.
6471 */ 6471 */
6472 FormalParameterList _parseFormalParameterListAfterParen(Token leftParenthesis, 6472 FormalParameterList _parseFormalParameterListAfterParen(Token leftParenthesis,
6473 {bool inFunctionType = false}) { 6473 {bool inFunctionType: false}) {
6474 if (_matches(TokenType.CLOSE_PAREN)) { 6474 if (_matches(TokenType.CLOSE_PAREN)) {
6475 return astFactory.formalParameterList( 6475 return astFactory.formalParameterList(
6476 leftParenthesis, null, null, null, getAndAdvance()); 6476 leftParenthesis, null, null, null, getAndAdvance());
6477 } 6477 }
6478 // 6478 //
6479 // Even though it is invalid to have default parameters outside of brackets, 6479 // Even though it is invalid to have default parameters outside of brackets,
6480 // required parameters inside of brackets, or multiple groups of default and 6480 // required parameters inside of brackets, or multiple groups of default and
6481 // named parameters, we allow all of these cases so that we can recover 6481 // named parameters, we allow all of these cases so that we can recover
6482 // better. 6482 // better.
6483 // 6483 //
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
6627 leftSquareBracket, rightSquareBracket, rightParenthesis); 6627 leftSquareBracket, rightSquareBracket, rightParenthesis);
6628 } 6628 }
6629 6629
6630 /** 6630 /**
6631 * Parse a list of formal parameters. Return the formal parameters that were 6631 * Parse a list of formal parameters. Return the formal parameters that were
6632 * parsed. 6632 * parsed.
6633 * 6633 *
6634 * This method assumes that the current token matches `TokenType.OPEN_PAREN`. 6634 * This method assumes that the current token matches `TokenType.OPEN_PAREN`.
6635 */ 6635 */
6636 FormalParameterList _parseFormalParameterListUnchecked( 6636 FormalParameterList _parseFormalParameterListUnchecked(
6637 {bool inFunctionType = false}) { 6637 {bool inFunctionType: false}) {
6638 return _parseFormalParameterListAfterParen(getAndAdvance(), 6638 return _parseFormalParameterListAfterParen(getAndAdvance(),
6639 inFunctionType: inFunctionType); 6639 inFunctionType: inFunctionType);
6640 } 6640 }
6641 6641
6642 /** 6642 /**
6643 * Parse a function declaration statement. The [commentAndMetadata] is the 6643 * Parse a function declaration statement. The [commentAndMetadata] is the
6644 * documentation comment and metadata to be associated with the declaration. 6644 * documentation comment and metadata to be associated with the declaration.
6645 * The [returnType] is the return type, or `null` if there is no return type. 6645 * The [returnType] is the return type, or `null` if there is no return type.
6646 * Return the function declaration statement that was parsed. 6646 * Return the function declaration statement that was parsed.
6647 * 6647 *
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
8294 */ 8294 */
8295 Parser_SyntheticKeywordToken(Keyword keyword, int offset) 8295 Parser_SyntheticKeywordToken(Keyword keyword, int offset)
8296 : super(keyword, offset); 8296 : super(keyword, offset);
8297 8297
8298 @override 8298 @override
8299 int get length => 0; 8299 int get length => 0;
8300 8300
8301 @override 8301 @override
8302 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); 8302 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset);
8303 } 8303 }
OLDNEW
« 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