From b37bd70b602b7ac6427dcf29f7cd9241b0a7ae09 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 10 Aug 2024 16:03:41 -0400 Subject: For tables, deprecate support for square bracket indexing and .default values, replacing them with a `:bump()` function for tables with numeric values. This means that counters can be implemented easily without the need to mask complexity. --- parse.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index 2b7b5816..4c9e95aa 100644 --- a/parse.c +++ b/parse.c @@ -743,7 +743,7 @@ PARSER(parse_table) { whitespace(&pos); - ast_t *fallback = NULL, *default_val = NULL; + ast_t *fallback = NULL; if (match(&pos, ";")) { for (;;) { whitespace(&pos); @@ -754,12 +754,6 @@ PARSER(parse_table) { if (fallback) parser_err(ctx, attr_start, pos, "This table already has a fallback"); fallback = expect(ctx, attr_start, &pos, parse_expr, "I expected a fallback table"); - } else if (match(&pos, "default")) { - whitespace(&pos); - if (!match(&pos, "=")) parser_err(ctx, attr_start, pos, "I expected an '=' after 'default'"); - if (default_val) - parser_err(ctx, attr_start, pos, "This table already has a default value"); - default_val = expect(ctx, attr_start, &pos, parse_expr, "I expected a default value for this table"); } else { break; } @@ -771,7 +765,7 @@ PARSER(parse_table) { whitespace(&pos); expect_closing(ctx, &pos, "}", "I wasn't able to parse the rest of this table"); - return NewAST(ctx->file, start, pos, Table, .key_type=key_type, .value_type=value_type, .entries=entries, .fallback=fallback, .default_value=default_val); + return NewAST(ctx->file, start, pos, Table, .key_type=key_type, .value_type=value_type, .entries=entries, .fallback=fallback); } PARSER(parse_set) { -- cgit v1.2.3