parseTernary parses the branches of a conditional whose condition, lhs, is condDepth deep, and leaves the depth of the conditional in lastParsedDepth.
(lhs ast.Expr, condDepth int)
| 524 | // parseTernary parses the branches of a conditional whose condition, lhs, is condDepth deep, |
| 525 | // and leaves the depth of the conditional in lastParsedDepth. |
| 526 | func (p *prattParserWorker) parseTernary(lhs ast.Expr, condDepth int) ast.Expr { |
| 527 | qTok := p.nextToken() |
| 528 | opID := p.nextID(qTok) |
| 529 | trueExpr := p.parseBinaryAndTernary(1) |
| 530 | depth := max(condDepth, p.lastParsedDepth) |
| 531 | if !p.expect(tokColon, "expected ':' in conditional expression") { |
| 532 | p.lastParsedDepth = condDepth |
| 533 | return lhs |
| 534 | } |
| 535 | falseExpr := p.parseExpr() |
| 536 | // The conditional node sits one level above the deepest of its operands. |
| 537 | depth = max(depth, p.lastParsedDepth) + 1 |
| 538 | p.lastParsedDepth = depth |
| 539 | p.checkRecursion(depth) |
| 540 | return p.helper.newGlobalCall(opID, operators.Conditional, lhs, trueExpr, falseExpr) |
| 541 | } |
| 542 | |
| 543 | // parseLogicalChain parses a run of '&&' or '||' operators following lhs, which is lhsDepth |
| 544 | // deep, and leaves the depth of the resulting expression in lastParsedDepth. Logical operators |
no test coverage detected