()
| 729 | // decorators: decorator+ |
| 730 | // decorated: decorators (classdef | funcdef | async_funcdef) |
| 731 | private _parseDecorated(): StatementNode | undefined { |
| 732 | let decoratorList: DecoratorNode[] = []; |
| 733 | |
| 734 | while (true) { |
| 735 | if (this._peekOperatorType() === OperatorType.MatrixMultiply) { |
| 736 | decoratorList.push(this._parseDecorator()); |
| 737 | } else { |
| 738 | break; |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | let nextToken = this._peekToken() as KeywordToken; |
| 743 | if (nextToken.type === TokenType.Keyword) { |
| 744 | if (nextToken.keywordType === KeywordType.Async) { |
| 745 | this._getNextToken(); |
| 746 | |
| 747 | if (this._peekKeywordType() !== KeywordType.Def) { |
| 748 | this._addError('Expected function definition after "async"', this._peekToken()); |
| 749 | return undefined; |
| 750 | } |
| 751 | return this._parseFunctionDef(nextToken, decoratorList); |
| 752 | } else if (nextToken.keywordType === KeywordType.Def) { |
| 753 | return this._parseFunctionDef(undefined, decoratorList); |
| 754 | } else if (nextToken.keywordType === KeywordType.Class) { |
| 755 | return this._parseClassDef(decoratorList); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | this._addError('Expected function or class declaration after decorator', this._peekToken()); |
| 760 | return undefined; |
| 761 | } |
| 762 | |
| 763 | // decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE |
| 764 | private _parseDecorator(): DecoratorNode { |
no test coverage detected