Parse one function argument: a string/number literal or a var[.prop]. */
| 1549 | |
| 1550 | /* Parse one function argument: a string/number literal or a var[.prop]. */ |
| 1551 | static int parse_func_arg(parser_t *p, cbm_func_arg_t *arg) { |
| 1552 | memset(arg, 0, sizeof(*arg)); |
| 1553 | if (check(p, TOK_STRING) || check(p, TOK_NUMBER)) { |
| 1554 | arg->literal = heap_strdup(peek(p)->text); |
| 1555 | advance(p); |
| 1556 | return 0; |
| 1557 | } |
| 1558 | const cbm_token_t *var = expect(p, TOK_IDENT); |
| 1559 | if (!var) { |
| 1560 | return CBM_NOT_FOUND; |
| 1561 | } |
| 1562 | arg->variable = heap_strdup(var->text); |
| 1563 | if (match(p, TOK_DOT)) { |
| 1564 | const cbm_token_t *prop = expect(p, TOK_IDENT); |
| 1565 | if (prop) { |
| 1566 | arg->property = heap_strdup(prop->text); |
| 1567 | } |
| 1568 | } |
| 1569 | return 0; |
| 1570 | } |
| 1571 | |
| 1572 | /* Parse a multi-argument scalar call: coalesce(a, b, ...), substring(s, i[, n]), |
| 1573 | * replace(s, from, to), left(s, n), right(s, n). */ |
no test coverage detected