MCPcopy Index your code
hub / github.com/uber/aresdb / parseCall

Method parseCall

query/expr/parser.go:522–553  ·  view source on GitHub ↗

parseCall parses a function call. This function assumes the function name and LPAREN have been consumed.

(name string)

Source from the content-addressed store, hash-verified

520// parseCall parses a function call.
521// This function assumes the function name and LPAREN have been consumed.
522func (p *Parser) parseCall(name string) (*Call, error) {
523 name = strings.ToLower(name)
524 // If there's a right paren then just return immediately.
525 if tok, _, _ := p.scan(); tok == RPAREN {
526 return &Call{Name: name}, nil
527 }
528 p.unscan()
529
530 // Otherwise parse function call arguments.
531 var args []Expr
532 for {
533 // Parse an expression argument.
534 arg, err := p.ParseExpr(0)
535 if err != nil {
536 return nil, err
537 }
538 args = append(args, arg)
539
540 // If there's not a comma next then stop parsing arguments.
541 if tok, _, _ := p.scan(); tok != COMMA {
542 p.unscan()
543 break
544 }
545 }
546
547 // There should be a right parentheses at the end.
548 if tok, pos, lit := p.scan(); tok != RPAREN {
549 return nil, newParseError(tokstr(tok, lit), []string{")"}, pos)
550 }
551
552 return &Call{Name: name, Args: args}, nil
553}
554
555// scan returns the next token from the underlying scanner.
556func (p *Parser) scan() (tok Token, pos Pos, lit string) { return p.s.Scan() }

Callers 1

parseUnaryExprMethod · 0.95

Calls 5

scanMethod · 0.95
unscanMethod · 0.95
ParseExprMethod · 0.95
newParseErrorFunction · 0.85
tokstrFunction · 0.85

Tested by

no test coverage detected