MCPcopy Create free account
hub / github.com/cel-expr/cel-go / parseLogicalChain

Method parseLogicalChain

parser/pratt_parser.go:546–558  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
546func (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
560func (p *prattParserWorker) parseSelectorChain() ast.Expr {
561 p.lastParsedDepth = 0

Callers 1

Calls 7

newLogicManagerMethod · 0.95
nextTokenMethod · 0.95
parseBinaryAndTernaryMethod · 0.95
nextIDMethod · 0.95
addTermMethod · 0.80
toExprMethod · 0.80

Tested by

no test coverage detected