Download this file
| 1 | package calc |
| 2 | |
| 3 | // parseCallArgs parses a parenthesized, comma-separated argument list. The |
| 4 | // current token must be the opening '(' on entry; it consumes through the |
| 5 | // matching ')'. |
| 6 | func (p *parser) parseCallArgs() ([]Node, error) { |
| 7 | p.advance() // consume '(' |
| 8 | |
| 9 | if p.cur.kind == tRParen { |
| 10 | p.advance() |
| 11 | return nil, nil |
| 12 | } |
| 13 | |
| 14 | var args []Node |
| 15 | for { |
| 16 | arg, err := p.parseComparison() |
| 17 | if err != nil { |
| 18 | return nil, err |
| 19 | } |
| 20 | args = append(args, arg) |
| 21 | |
| 22 | if p.cur.kind == tComma { |
| 23 | p.advance() |
| 24 | continue |
| 25 | } |
| 26 | break |
| 27 | } |
| 28 | |
| 29 | if p.cur.kind != tRParen { |
| 30 | return nil, p.errorf("expected closing parenthesis") |
| 31 | } |
| 32 | p.advance() |
| 33 | return args, nil |
| 34 | } |
| 35 | |