| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 * Return `true` if the current token appears to be the beginning of a | 424 * Return `true` if the current token appears to be the beginning of a |
| 425 * function declaration. | 425 * function declaration. |
| 426 */ | 426 */ |
| 427 bool isFunctionDeclaration() { | 427 bool isFunctionDeclaration() { |
| 428 Keyword keyword = _currentToken.keyword; | 428 Keyword keyword = _currentToken.keyword; |
| 429 if (keyword == Keyword.VOID) { | 429 if (keyword == Keyword.VOID) { |
| 430 return true; | 430 return true; |
| 431 } | 431 } |
| 432 Token afterReturnType = skipTypeName(_currentToken); | 432 Token afterReturnType = skipTypeName(_currentToken); |
| 433 if (afterReturnType != null && | 433 if (afterReturnType != null && |
| 434 _tokenMatchesKeyword(afterReturnType, Keyword.FUNCTION)) { | 434 _tokenMatchesString(afterReturnType, 'Function')) { |
| 435 afterReturnType = skipGenericFunctionTypeAfterReturnType(afterReturnType); | 435 afterReturnType = skipGenericFunctionTypeAfterReturnType(afterReturnType); |
| 436 } | 436 } |
| 437 if (afterReturnType == null) { | 437 if (afterReturnType == null) { |
| 438 // There was no return type, but it is optional, so go back to where we | 438 // There was no return type, but it is optional, so go back to where we |
| 439 // started. | 439 // started. |
| 440 afterReturnType = _currentToken; | 440 afterReturnType = _currentToken; |
| 441 } | 441 } |
| 442 Token afterIdentifier = skipSimpleIdentifier(afterReturnType); | 442 Token afterIdentifier = skipSimpleIdentifier(afterReturnType); |
| 443 if (afterIdentifier == null) { | 443 if (afterIdentifier == null) { |
| 444 // It's possible that we parsed the function name as if it were a type | 444 // It's possible that we parsed the function name as if it were a type |
| (...skipping 3722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4167 // block. Parse it as a variable declaration. | 4167 // block. Parse it as a variable declaration. |
| 4168 // | 4168 // |
| 4169 return _parseVariableDeclarationStatementAfterType( | 4169 return _parseVariableDeclarationStatementAfterType( |
| 4170 commentAndMetadata, null, returnType); | 4170 commentAndMetadata, null, returnType); |
| 4171 } | 4171 } |
| 4172 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT); | 4172 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT); |
| 4173 // TODO(brianwilkerson) Recover from this error. | 4173 // TODO(brianwilkerson) Recover from this error. |
| 4174 return astFactory | 4174 return astFactory |
| 4175 .emptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); | 4175 .emptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); |
| 4176 } | 4176 } |
| 4177 } else if (_inGenerator && _matchesKeyword(Keyword.YIELD)) { | 4177 } else if (_inGenerator && _matchesString(_YIELD)) { |
| 4178 return parseYieldStatement(); | 4178 return parseYieldStatement(); |
| 4179 } else if (_inAsync && _matchesString(_AWAIT)) { | 4179 } else if (_inAsync && _matchesString(_AWAIT)) { |
| 4180 if (_tokenMatchesKeyword(_peek(), Keyword.FOR)) { | 4180 if (_tokenMatchesKeyword(_peek(), Keyword.FOR)) { |
| 4181 return parseForStatement(); | 4181 return parseForStatement(); |
| 4182 } | 4182 } |
| 4183 return astFactory.expressionStatement( | 4183 return astFactory.expressionStatement( |
| 4184 parseExpression2(), _expect(TokenType.SEMICOLON)); | 4184 parseExpression2(), _expect(TokenType.SEMICOLON)); |
| 4185 } else if (_matchesString(_AWAIT) && | 4185 } else if (_matchesString(_AWAIT) && |
| 4186 _tokenMatchesKeyword(_peek(), Keyword.FOR)) { | 4186 _tokenMatchesKeyword(_peek(), Keyword.FOR)) { |
| 4187 Token awaitToken = _currentToken; | 4187 Token awaitToken = _currentToken; |
| (...skipping 4408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8596 */ | 8596 */ |
| 8597 Parser_SyntheticKeywordToken(Keyword keyword, int offset) | 8597 Parser_SyntheticKeywordToken(Keyword keyword, int offset) |
| 8598 : super(keyword, offset); | 8598 : super(keyword, offset); |
| 8599 | 8599 |
| 8600 @override | 8600 @override |
| 8601 int get length => 0; | 8601 int get length => 0; |
| 8602 | 8602 |
| 8603 @override | 8603 @override |
| 8604 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); | 8604 Token copy() => new Parser_SyntheticKeywordToken(keyword, offset); |
| 8605 } | 8605 } |
| OLD | NEW |