(token Token, arguments []Node, checkOverrides bool)
| 567 | } |
| 568 | |
| 569 | func (p *Parser) parseCall(token Token, arguments []Node, checkOverrides bool) Node { |
| 570 | var node Node |
| 571 | |
| 572 | isOverridden := false |
| 573 | if p.config != nil { |
| 574 | isOverridden = p.config.IsOverridden(token.Value) |
| 575 | } |
| 576 | isOverridden = isOverridden && checkOverrides |
| 577 | |
| 578 | if b, ok := predicates[token.Value]; ok && !isOverridden { |
| 579 | p.expect(Bracket, "(") |
| 580 | |
| 581 | // In case of the pipe operator, the first argument is the left-hand side |
| 582 | // of the operator, so we do not parse it as an argument inside brackets. |
| 583 | args := b.args[len(arguments):] |
| 584 | |
| 585 | for i, arg := range args { |
| 586 | if arg&optional == optional { |
| 587 | if p.current.Is(Bracket, ")") { |
| 588 | break |
| 589 | } |
| 590 | } else { |
| 591 | if p.current.Is(Bracket, ")") { |
| 592 | p.error("expected at least %d arguments", len(args)) |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | if i > 0 { |
| 597 | p.expect(Operator, ",") |
| 598 | } |
| 599 | var node Node |
| 600 | switch { |
| 601 | case arg&expr == expr: |
| 602 | node = p.parseExpression(0) |
| 603 | case arg&predicate == predicate: |
| 604 | node = p.parsePredicate() |
| 605 | } |
| 606 | arguments = append(arguments, node) |
| 607 | } |
| 608 | |
| 609 | // skip last comma |
| 610 | if p.current.Is(Operator, ",") { |
| 611 | p.next() |
| 612 | } |
| 613 | p.expect(Bracket, ")") |
| 614 | |
| 615 | node = p.createNode(&BuiltinNode{ |
| 616 | Name: token.Value, |
| 617 | Arguments: arguments, |
| 618 | }, token.Location) |
| 619 | if node == nil { |
| 620 | return nil |
| 621 | } |
| 622 | } else if _, ok := builtin.Index[token.Value]; ok && (p.config == nil || !p.config.Disabled[token.Value]) && !isOverridden { |
| 623 | node = p.createNode(&BuiltinNode{ |
| 624 | Name: token.Value, |
| 625 | Arguments: p.parseArguments(arguments), |
| 626 | }, token.Location) |
no test coverage detected