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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 modifiers.finalKeyword ?? | 1331 modifiers.finalKeyword ?? |
1332 modifiers.constKeyword; | 1332 modifiers.constKeyword; |
1333 if (keyword != null) { | 1333 if (keyword != null) { |
1334 // | 1334 // |
1335 // We appear to have found an incomplete field declaration. | 1335 // We appear to have found an incomplete field declaration. |
1336 // | 1336 // |
1337 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); | 1337 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); |
1338 VariableDeclaration variable = astFactory.variableDeclaration( | 1338 VariableDeclaration variable = astFactory.variableDeclaration( |
1339 createSyntheticIdentifier(), null, null); | 1339 createSyntheticIdentifier(), null, null); |
1340 List<VariableDeclaration> variables = <VariableDeclaration>[variable]; | 1340 List<VariableDeclaration> variables = <VariableDeclaration>[variable]; |
1341 FieldDeclarationImpl field = astFactory.fieldDeclaration( | 1341 return astFactory.fieldDeclaration2( |
1342 commentAndMetadata.comment, | 1342 comment: commentAndMetadata.comment, |
1343 commentAndMetadata.metadata, | 1343 metadata: commentAndMetadata.metadata, |
1344 null, | 1344 covariantKeyword: modifiers.covariantKeyword, |
1345 astFactory.variableDeclarationList( | 1345 fieldList: astFactory.variableDeclarationList( |
1346 null, null, keyword, null, variables), | 1346 null, null, keyword, null, variables), |
1347 _expect(TokenType.SEMICOLON)); | 1347 semicolon: _expect(TokenType.SEMICOLON)); |
1348 field.covariantKeyword = modifiers.covariantKeyword; | |
1349 return field; | |
1350 } | 1348 } |
1351 _reportErrorForToken( | 1349 _reportErrorForToken( |
1352 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken); | 1350 ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken); |
1353 if (commentAndMetadata.comment != null || | 1351 if (commentAndMetadata.comment != null || |
1354 commentAndMetadata.hasMetadata) { | 1352 commentAndMetadata.hasMetadata) { |
1355 // | 1353 // |
1356 // We appear to have found an incomplete declaration at the end of the | 1354 // We appear to have found an incomplete declaration at the end of the |
1357 // class. At this point it consists of a metadata, which we don't want | 1355 // class. At this point it consists of a metadata, which we don't want |
1358 // to loose, so we'll treat it as a method declaration with a missing | 1356 // to loose, so we'll treat it as a method declaration with a missing |
1359 // name, parameters and empty body. | 1357 // name, parameters and empty body. |
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3577 * identifier ('=' expression)? | 3575 * identifier ('=' expression)? |
3578 */ | 3576 */ |
3579 FieldDeclaration parseInitializedIdentifierList( | 3577 FieldDeclaration parseInitializedIdentifierList( |
3580 CommentAndMetadata commentAndMetadata, | 3578 CommentAndMetadata commentAndMetadata, |
3581 Token staticKeyword, | 3579 Token staticKeyword, |
3582 Token covariantKeyword, | 3580 Token covariantKeyword, |
3583 Token keyword, | 3581 Token keyword, |
3584 TypeAnnotation type) { | 3582 TypeAnnotation type) { |
3585 VariableDeclarationList fieldList = | 3583 VariableDeclarationList fieldList = |
3586 parseVariableDeclarationListAfterType(null, keyword, type); | 3584 parseVariableDeclarationListAfterType(null, keyword, type); |
3587 FieldDeclarationImpl field = astFactory.fieldDeclaration( | 3585 return astFactory.fieldDeclaration2( |
3588 commentAndMetadata.comment, | 3586 comment: commentAndMetadata.comment, |
3589 commentAndMetadata.metadata, | 3587 metadata: commentAndMetadata.metadata, |
3590 staticKeyword, | 3588 covariantKeyword: covariantKeyword, |
3591 fieldList, | 3589 staticKeyword: staticKeyword, |
3592 _expect(TokenType.SEMICOLON)); | 3590 fieldList: fieldList, |
3593 field.covariantKeyword = covariantKeyword; | 3591 semicolon: _expect(TokenType.SEMICOLON)); |
3594 return field; | |
3595 } | 3592 } |
3596 | 3593 |
3597 /** | 3594 /** |
3598 * Parse an instance creation expression. The [keyword] is the 'new' or | 3595 * Parse an instance creation expression. The [keyword] is the 'new' or |
3599 * 'const' keyword that introduces the expression. Return the instance | 3596 * 'const' keyword that introduces the expression. Return the instance |
3600 * creation expression that was parsed. | 3597 * creation expression that was parsed. |
3601 * | 3598 * |
3602 * instanceCreationExpression ::= | 3599 * instanceCreationExpression ::= |
3603 * ('new' | 'const') type ('.' identifier)? argumentList | 3600 * ('new' | 'const') type ('.' identifier)? argumentList |
3604 */ | 3601 */ |
(...skipping 4897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8502 */ | 8499 */ |
8503 Parser_SyntheticKeywordToken(Keyword keyword, int offset) | 8500 Parser_SyntheticKeywordToken(Keyword keyword, int offset) |
8504 : super(keyword, offset); | 8501 : super(keyword, offset); |
8505 | 8502 |
8506 @override | 8503 @override |
8507 int get length => 0; | 8504 int get length => 0; |
8508 | 8505 |
8509 @override | 8506 @override |
8510 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); | 8507 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); |
8511 } | 8508 } |
OLD | NEW |