Parse one function argument: a string/number literal or a var[.prop]. */
| 1579 | |
| 1580 | /* Parse one function argument: a string/number literal or a var[.prop]. */ |
| 1581 | static int parse_func_arg(parser_t *p, cbm_func_arg_t *arg) { |
| 1582 | memset(arg, 0, sizeof(*arg)); |
| 1583 | if (check(p, TOK_STRING) || check(p, TOK_NUMBER)) { |
| 1584 | arg->literal = heap_strdup(peek(p)->text); |
| 1585 | advance(p); |
| 1586 | return 0; |
| 1587 | } |
| 1588 | const cbm_token_t *var = expect(p, TOK_IDENT); |
| 1589 | if (!var) { |
| 1590 | return CBM_NOT_FOUND; |
| 1591 | } |
| 1592 | arg->variable = heap_strdup(var->text); |
| 1593 | if (match(p, TOK_DOT)) { |
| 1594 | const cbm_token_t *prop = expect(p, TOK_IDENT); |
| 1595 | if (prop) { |
| 1596 | arg->property = heap_strdup(prop->text); |
| 1597 | } |
| 1598 | } |
| 1599 | return 0; |
| 1600 | } |
| 1601 | |
| 1602 | /* Parse a multi-argument scalar call: coalesce(a, b, ...), substring(s, i[, n]), |
| 1603 | * replace(s, from, to), left(s, n), right(s, n). */ |
no test coverage detected