promql/parse.go
func (p *parser) call(name string) *Call {
	const ctx = "function call"

	fn, exist := getFunction(name)
	if !exist {
		p.errorf("unknown function with name %q", name)
	}

	p.expect(ItemLeftParen, ctx)
	// Might be call without args.
	if p.peek().typ == ItemRightParen {
		p.next() // Consume.
		return &Call{fn, nil}
	}

	var args []Expr
	for {
		e := p.expr()
		args = append(args, e)

		// Terminate if no more arguments.
		if p.peek().typ != ItemComma {
			break
		}
		p.next()
	}

	// Call must be closed.
	p.expect(ItemRightParen, ctx)

	return &Call{Func: fn, Args: args}
}
func (p *parser) call(name string) *Call {
	const ctx = "function call"

	fn, exist := getFunction(name)
	if !exist {
		p.errorf("unknown function with name %q", name)
	}

	p.expect(ItemLeftParen, ctx)
	// Might be call without args.
	if p.peek().typ == ItemRightParen {
		p.next() // Consume.
		return &Call{fn, nil}
	}

	var args []Expr
	for {
		e := p.expr()
		args = append(args, e)

		// Terminate if no more arguments.
		if p.peek().typ != ItemComma {
			break
		}
		p.next()
	}

	// Call must be closed.
	p.expect(ItemRightParen, ctx)

	return &Call{Func: fn, Args: args}
}
// call parses a function call.
//
//		<func_name> '(' [ <arg_expr>, ...] ')'
//