From 7e8604daeb9239e1669c5414dd6caa37af30c4ff Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 11 Oct 2025 15:31:38 -0400 Subject: Make `{a,b,c}` shorthand for `{a:Empty(), b:Empty(), c:Empty()}` and display it that way. Same for type annotations. --- src/parse/containers.c | 6 +++--- src/parse/types.c | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/parse') diff --git a/src/parse/containers.c b/src/parse/containers.c index 55ff336e..8f9922f3 100644 --- a/src/parse/containers.c +++ b/src/parse/containers.c @@ -2,7 +2,6 @@ #include #include -#include #include "../ast.h" #include "../stdlib/util.h" @@ -50,8 +49,9 @@ ast_t *parse_table(parse_ctx_t *ctx, const char *pos) { ast_t *key = optional(ctx, &pos, parse_extended_expr); if (!key) break; whitespace(ctx, &pos); - if (!match(&pos, ":")) return NULL; - ast_t *value = expect(ctx, pos - 1, &pos, parse_expr, "I couldn't parse the value for this table entry"); + ast_t *value = NULL; + if (match(&pos, ":")) + value = expect(ctx, pos - 1, &pos, parse_expr, "I couldn't parse the value for this table entry"); ast_t *entry = NewAST(ctx->file, entry_start, pos, TableEntry, .key = key, .value = value); ast_t *suffixed = parse_comprehension_suffix(ctx, entry); while (suffixed) { diff --git a/src/parse/types.c b/src/parse/types.c index 192103dc..8ecc602e 100644 --- a/src/parse/types.c +++ b/src/parse/types.c @@ -27,8 +27,6 @@ type_ast_t *parse_table_type(parse_ctx_t *ctx, const char *pos) { type_ast_t *value_type = NULL; if (match(&pos, ":")) { value_type = expect(ctx, start, &pos, parse_type, "I couldn't parse the rest of this table type"); - } else { - return NULL; } spaces(&pos); ast_t *default_value = NULL; -- cgit v1.2.3