From fb216e955f04a803f11953be27e76bd4d2c9e76d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 6 Sep 2025 15:11:26 -0400 Subject: Use colons instead of '=' for tables (e.g. {1: 2}) --- src/parse/containers.c | 2 +- src/parse/types.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/parse') diff --git a/src/parse/containers.c b/src/parse/containers.c index 73d30ecd..c6362623 100644 --- a/src/parse/containers.c +++ b/src/parse/containers.c @@ -50,7 +50,7 @@ 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; + 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 *entry = NewAST(ctx->file, entry_start, pos, TableEntry, .key = key, .value = value); ast_t *suffixed = parse_comprehension_suffix(ctx, entry); diff --git a/src/parse/types.c b/src/parse/types.c index ffb7d869..987be7a1 100644 --- a/src/parse/types.c +++ b/src/parse/types.c @@ -23,15 +23,14 @@ type_ast_t *parse_table_type(parse_ctx_t *ctx, const char *pos) { pos = key_type->end; whitespace(ctx, &pos); type_ast_t *value_type = NULL; - if (match(&pos, "=")) { + 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; - if (match(&pos, ";") && match_word(&pos, "default")) { - expect_str(ctx, pos, &pos, "=", "I expected an '=' here"); + if (match(&pos, "=")) { default_value = expect(ctx, start, &pos, parse_extended_expr, "I couldn't parse the default value for this table"); } -- cgit v1.2.3