()
| 153 | // compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt |
| 154 | // | funcdef | classdef | decorated | async_stmt |
| 155 | private _parseStatement(): StatementNode | undefined { |
| 156 | // Handle the errant condition of a dedent token here to provide |
| 157 | // better recovery. |
| 158 | if (this._consumeTokenIfType(TokenType.Dedent)) { |
| 159 | this._addError('Unindent not expected', this._peekToken()); |
| 160 | } |
| 161 | |
| 162 | switch (this._peekKeywordType()) { |
| 163 | case KeywordType.If: |
| 164 | return this._parseIfStatement(); |
| 165 | |
| 166 | case KeywordType.While: |
| 167 | return this._parseWhileStatement(); |
| 168 | |
| 169 | case KeywordType.For: |
| 170 | return this._parseForStatement(); |
| 171 | |
| 172 | case KeywordType.Try: |
| 173 | return this._parseTryStatement(); |
| 174 | |
| 175 | case KeywordType.With: |
| 176 | return this._parseWithStatement(); |
| 177 | |
| 178 | case KeywordType.Def: |
| 179 | return this._parseFunctionDef(); |
| 180 | |
| 181 | case KeywordType.Class: |
| 182 | return this._parseClassDef(); |
| 183 | |
| 184 | case KeywordType.Async: |
| 185 | return this._parseAsyncStatement(); |
| 186 | } |
| 187 | |
| 188 | if (this._peekOperatorType() === OperatorType.MatrixMultiply) { |
| 189 | return this._parseDecorated(); |
| 190 | } |
| 191 | |
| 192 | return this._parseSimpleStatement(); |
| 193 | } |
| 194 | |
| 195 | // async_stmt: 'async' (funcdef | with_stmt | for_stmt) |
| 196 | private _parseAsyncStatement(): StatementNode | undefined { |
no test coverage detected