| 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 3336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3347 CommentAndMetadata commentAndMetadata, Token keyword) { | 3347 CommentAndMetadata commentAndMetadata, Token keyword) { |
| 3348 Identifier name = _parseSimpleIdentifierUnchecked(isDeclaration: true); | 3348 Identifier name = _parseSimpleIdentifierUnchecked(isDeclaration: true); |
| 3349 TypeParameterList typeParameters = null; | 3349 TypeParameterList typeParameters = null; |
| 3350 if (_matches(TokenType.LT)) { | 3350 if (_matches(TokenType.LT)) { |
| 3351 typeParameters = parseTypeParameterList(); | 3351 typeParameters = parseTypeParameterList(); |
| 3352 } | 3352 } |
| 3353 Token equals = _expect(TokenType.EQ); | 3353 Token equals = _expect(TokenType.EQ); |
| 3354 TypeAnnotation functionType = parseTypeAnnotation(false); | 3354 TypeAnnotation functionType = parseTypeAnnotation(false); |
| 3355 Token semicolon = _expect(TokenType.SEMICOLON); | 3355 Token semicolon = _expect(TokenType.SEMICOLON); |
| 3356 if (functionType is! GenericFunctionType) { | 3356 if (functionType is! GenericFunctionType) { |
| 3357 // TODO(brianwilkerson) Generate an error and recover (better than this). | 3357 // TODO(brianwilkerson) Generate a better error. |
| 3358 _reportErrorForToken( |
| 3359 ParserErrorCode.INVALID_GENERIC_FUNCTION_TYPE, semicolon); |
| 3360 // TODO(brianwilkerson) Recover better than this. |
| 3358 return astFactory.genericTypeAlias( | 3361 return astFactory.genericTypeAlias( |
| 3359 commentAndMetadata.comment, | 3362 commentAndMetadata.comment, |
| 3360 commentAndMetadata.metadata, | 3363 commentAndMetadata.metadata, |
| 3361 keyword, | 3364 keyword, |
| 3362 name, | 3365 name, |
| 3363 typeParameters, | 3366 typeParameters, |
| 3364 equals, | 3367 equals, |
| 3365 null, | 3368 null, |
| 3366 semicolon); | 3369 semicolon); |
| 3367 } | 3370 } |
| (...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5625 * This method must be kept in sync with [parseTypeParameterList]. | 5628 * This method must be kept in sync with [parseTypeParameterList]. |
| 5626 */ | 5629 */ |
| 5627 Token skipTypeParameterList(Token startToken) { | 5630 Token skipTypeParameterList(Token startToken) { |
| 5628 if (!_tokenMatches(startToken, TokenType.LT)) { | 5631 if (!_tokenMatches(startToken, TokenType.LT)) { |
| 5629 return null; | 5632 return null; |
| 5630 } | 5633 } |
| 5631 int depth = 1; | 5634 int depth = 1; |
| 5632 Token previous = startToken; | 5635 Token previous = startToken; |
| 5633 Token next = startToken.next; | 5636 Token next = startToken.next; |
| 5634 while (next != previous) { | 5637 while (next != previous) { |
| 5635 if (_tokenMatches(startToken, TokenType.LT)) { | 5638 if (_tokenMatches(next, TokenType.LT)) { |
| 5636 depth++; | 5639 depth++; |
| 5637 } else if (_tokenMatches(next, TokenType.GT)) { | 5640 } else if (_tokenMatches(next, TokenType.GT)) { |
| 5638 depth--; | 5641 depth--; |
| 5639 if (depth == 0) { | 5642 if (depth == 0) { |
| 5640 return next; | 5643 return next; |
| 5641 } | 5644 } |
| 5642 } | 5645 } |
| 5643 previous = next; | 5646 previous = next; |
| 5644 next = next.next; | 5647 next = next.next; |
| 5645 } | 5648 } |
| (...skipping 2860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8506 */ | 8509 */ |
| 8507 Parser_SyntheticKeywordToken(Keyword keyword, int offset) | 8510 Parser_SyntheticKeywordToken(Keyword keyword, int offset) |
| 8508 : super(keyword, offset); | 8511 : super(keyword, offset); |
| 8509 | 8512 |
| 8510 @override | 8513 @override |
| 8511 int get length => 0; | 8514 int get length => 0; |
| 8512 | 8515 |
| 8513 @override | 8516 @override |
| 8514 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); | 8517 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); |
| 8515 } | 8518 } |
| OLD | NEW |