parseLogicalChain parses a run of '&&' or '||' operators following lhs, which is lhsDepth deep, and leaves the depth of the resulting expression in lastParsedDepth. Logical operators do not add to the depth: the chain is as deep as its deepest term.
(lhs ast.Expr, opInfo binaryOpInfo, lhsDepth int)
| 544 | // deep, and leaves the depth of the resulting expression in lastParsedDepth. Logical operators |
| 545 | // do not add to the depth: the chain is as deep as its deepest term. |
| 546 | func (p *prattParserWorker) parseLogicalChain(lhs ast.Expr, opInfo binaryOpInfo, lhsDepth int) ast.Expr { |
| 547 | depth := lhsDepth |
| 548 | l := p.newLogicManager(opInfo.name, lhs) |
| 549 | for !p.recursionLimitExceeded && !p.isRecoveryLimitExceeded() && p.peekTok.kind == opInfo.kind { |
| 550 | opTok := p.nextToken() |
| 551 | rhs := p.parseBinaryAndTernary(opInfo.precedence + 1) |
| 552 | depth = max(depth, p.lastParsedDepth) |
| 553 | opID := p.nextID(opTok) |
| 554 | l.addTerm(opID, rhs) |
| 555 | } |
| 556 | p.lastParsedDepth = depth |
| 557 | return l.toExpr() |
| 558 | } |
| 559 | |
| 560 | func (p *prattParserWorker) parseSelectorChain() ast.Expr { |
| 561 | p.lastParsedDepth = 0 |
no test coverage detected