| 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/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 4201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4212 } | 4212 } |
| 4213 // Consume all operator tokens. | 4213 // Consume all operator tokens. |
| 4214 Token token = startToken.next; | 4214 Token token = startToken.next; |
| 4215 while (token.isOperator) { | 4215 while (token.isOperator) { |
| 4216 token = token.next; | 4216 token = token.next; |
| 4217 } | 4217 } |
| 4218 // Formal parameter list is expect now. | 4218 // Formal parameter list is expect now. |
| 4219 return _tokenMatches(token, TokenType.OPEN_PAREN); | 4219 return _tokenMatches(token, TokenType.OPEN_PAREN); |
| 4220 } | 4220 } |
| 4221 | 4221 |
| 4222 bool _isPeekGenericTypeParametersAndOpenParen() { |
| 4223 if (!parseGenericMethods) { |
| 4224 return false; |
| 4225 } |
| 4226 Token token = _skipTypeArgumentList(_peek()); |
| 4227 return token != null && _tokenMatches(token, TokenType.OPEN_PAREN); |
| 4228 } |
| 4229 |
| 4222 /** | 4230 /** |
| 4223 * Return `true` if the current token appears to be the beginning of a switch | 4231 * Return `true` if the current token appears to be the beginning of a switch |
| 4224 * member. | 4232 * member. |
| 4225 */ | 4233 */ |
| 4226 bool _isSwitchMember() { | 4234 bool _isSwitchMember() { |
| 4227 Token token = _currentToken; | 4235 Token token = _currentToken; |
| 4228 while (_tokenMatches(token, TokenType.IDENTIFIER) && | 4236 while (_tokenMatches(token, TokenType.IDENTIFIER) && |
| 4229 _tokenMatches(token.next, TokenType.COLON)) { | 4237 _tokenMatches(token.next, TokenType.COLON)) { |
| 4230 token = token.next.next; | 4238 token = token.next.next; |
| 4231 } | 4239 } |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5209 variables.add( | 5217 variables.add( |
| 5210 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); | 5218 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); |
| 5211 return new TopLevelVariableDeclaration( | 5219 return new TopLevelVariableDeclaration( |
| 5212 commentAndMetadata.comment, | 5220 commentAndMetadata.comment, |
| 5213 commentAndMetadata.metadata, | 5221 commentAndMetadata.metadata, |
| 5214 new VariableDeclarationList(null, null, keyword, null, variables), | 5222 new VariableDeclarationList(null, null, keyword, null, variables), |
| 5215 _expectSemicolon()); | 5223 _expectSemicolon()); |
| 5216 } | 5224 } |
| 5217 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); | 5225 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken); |
| 5218 return null; | 5226 return null; |
| 5227 } else if (_isPeekGenericTypeParametersAndOpenParen()) { |
| 5228 return _parseFunctionDeclaration( |
| 5229 commentAndMetadata, modifiers.externalKeyword, null); |
| 5219 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { | 5230 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 5220 TypeName returnType = _parseOptionalTypeNameComment(); | 5231 TypeName returnType = _parseOptionalTypeNameComment(); |
| 5221 _validateModifiersForTopLevelFunction(modifiers); | 5232 _validateModifiersForTopLevelFunction(modifiers); |
| 5222 return _parseFunctionDeclaration( | 5233 return _parseFunctionDeclaration( |
| 5223 commentAndMetadata, modifiers.externalKeyword, returnType); | 5234 commentAndMetadata, modifiers.externalKeyword, returnType); |
| 5224 } else if (_peek() | 5235 } else if (_peek() |
| 5225 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { | 5236 .matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMICOLON])) { |
| 5226 if (modifiers.constKeyword == null && | 5237 if (modifiers.constKeyword == null && |
| 5227 modifiers.finalKeyword == null && | 5238 modifiers.finalKeyword == null && |
| 5228 modifiers.varKeyword == null) { | 5239 modifiers.varKeyword == null) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5268 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); | 5279 new VariableDeclaration(_createSyntheticIdentifier(), null, null)); |
| 5269 return new TopLevelVariableDeclaration( | 5280 return new TopLevelVariableDeclaration( |
| 5270 commentAndMetadata.comment, | 5281 commentAndMetadata.comment, |
| 5271 commentAndMetadata.metadata, | 5282 commentAndMetadata.metadata, |
| 5272 new VariableDeclarationList(null, null, null, returnType, variables), | 5283 new VariableDeclarationList(null, null, null, returnType, variables), |
| 5273 semicolon); | 5284 semicolon); |
| 5274 } | 5285 } |
| 5275 if (_peek().matchesAny([ | 5286 if (_peek().matchesAny([ |
| 5276 TokenType.OPEN_PAREN, | 5287 TokenType.OPEN_PAREN, |
| 5277 TokenType.FUNCTION, | 5288 TokenType.FUNCTION, |
| 5278 TokenType.OPEN_CURLY_BRACKET | 5289 TokenType.OPEN_CURLY_BRACKET, |
| 5290 TokenType.LT |
| 5279 ])) { | 5291 ])) { |
| 5280 _validateModifiersForTopLevelFunction(modifiers); | 5292 _validateModifiersForTopLevelFunction(modifiers); |
| 5281 return _parseFunctionDeclaration( | 5293 return _parseFunctionDeclaration( |
| 5282 commentAndMetadata, modifiers.externalKeyword, returnType); | 5294 commentAndMetadata, modifiers.externalKeyword, returnType); |
| 5283 } | 5295 } |
| 5284 return new TopLevelVariableDeclaration( | 5296 return new TopLevelVariableDeclaration( |
| 5285 commentAndMetadata.comment, | 5297 commentAndMetadata.comment, |
| 5286 commentAndMetadata.metadata, | 5298 commentAndMetadata.metadata, |
| 5287 _parseVariableDeclarationListAfterType( | 5299 _parseVariableDeclarationListAfterType( |
| 5288 null, _validateModifiersForTopLevelVariable(modifiers), returnType), | 5300 null, _validateModifiersForTopLevelVariable(modifiers), returnType), |
| (...skipping 6030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11319 } | 11331 } |
| 11320 | 11332 |
| 11321 /** | 11333 /** |
| 11322 * Copy resolution data from the [fromNode] to the [toNode]. | 11334 * Copy resolution data from the [fromNode] to the [toNode]. |
| 11323 */ | 11335 */ |
| 11324 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 11336 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
| 11325 ResolutionCopier copier = new ResolutionCopier(); | 11337 ResolutionCopier copier = new ResolutionCopier(); |
| 11326 copier._isEqualNodes(fromNode, toNode); | 11338 copier._isEqualNodes(fromNode, toNode); |
| 11327 } | 11339 } |
| 11328 } | 11340 } |
| OLD | NEW |