()
| 1332 | |
| 1333 | // test: or_test ['if' or_test 'else' test] | lambdef |
| 1334 | private _parseTestExpression(): ExpressionNode { |
| 1335 | if (this._peekKeywordType() === KeywordType.Lambda) { |
| 1336 | return this._parseLambdaExpression(); |
| 1337 | } |
| 1338 | |
| 1339 | let ifExpr = this._parseOrTest(); |
| 1340 | if (ifExpr instanceof ErrorExpressionNode) { |
| 1341 | return ifExpr; |
| 1342 | } |
| 1343 | |
| 1344 | if (!this._consumeTokenIfKeyword(KeywordType.If)) { |
| 1345 | return ifExpr; |
| 1346 | } |
| 1347 | |
| 1348 | let testExpr = this._parseOrTest(); |
| 1349 | if (testExpr instanceof ErrorExpressionNode) { |
| 1350 | return testExpr; |
| 1351 | } |
| 1352 | |
| 1353 | if (!this._consumeTokenIfKeyword(KeywordType.Else)) { |
| 1354 | return this._handleExpressionParseError('Expected "else"'); |
| 1355 | } |
| 1356 | |
| 1357 | let elseExpr = this._parseTestExpression(); |
| 1358 | if (elseExpr instanceof ErrorExpressionNode) { |
| 1359 | return elseExpr; |
| 1360 | } |
| 1361 | |
| 1362 | return new ConditionalExpressionNode(ifExpr, testExpr, elseExpr); |
| 1363 | } |
| 1364 | |
| 1365 | // or_test: and_test ('or' and_test)* |
| 1366 | private _parseOrTest(): ExpressionNode { |
no test coverage detected