Parse a value literal: string, number, ident[.prop], true, false. Returns heap-allocated. */
| 1368 | |
| 1369 | /* Parse a value literal: string, number, ident[.prop], true, false. Returns heap-allocated. */ |
| 1370 | static const char *parse_value_literal(parser_t *p) { |
| 1371 | if (check(p, TOK_STRING) || check(p, TOK_NUMBER)) { |
| 1372 | return heap_strdup(advance(p)->text); |
| 1373 | } |
| 1374 | if (check(p, TOK_IDENT)) { |
| 1375 | char buf[CBM_SZ_256]; |
| 1376 | const cbm_token_t *v = advance(p); |
| 1377 | if (match(p, TOK_DOT)) { |
| 1378 | const cbm_token_t *pr = expect(p, TOK_IDENT); |
| 1379 | snprintf(buf, sizeof(buf), "%s.%s", v->text, pr ? pr->text : ""); |
| 1380 | } else { |
| 1381 | snprintf(buf, sizeof(buf), "%s", v->text); |
| 1382 | } |
| 1383 | return heap_strdup(buf); |
| 1384 | } |
| 1385 | if (check(p, TOK_TRUE)) { |
| 1386 | advance(p); |
| 1387 | return heap_strdup("true"); |
| 1388 | } |
| 1389 | if (check(p, TOK_FALSE)) { |
| 1390 | advance(p); |
| 1391 | return heap_strdup("false"); |
| 1392 | } |
| 1393 | return NULL; |
| 1394 | } |
| 1395 | |
| 1396 | /* Parse CASE WHEN ... THEN ... [ELSE ...] END */ |
| 1397 | static cbm_case_expr_t *parse_case_expr(parser_t *p) { |
no test coverage detected