aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-11 12:29:48 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-11 12:29:48 -0400
commit210179ee672a0c3799328a54e886f574b3823e3d (patch)
tree25ddb95503c537c19b9fdb7614df2f16c4012d21 /parse.c
parentdee3742b48e27ef36637d004163286d3352b0763 (diff)
Optional enums (deprecated custom tag values)
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c21
1 files changed, 1 insertions, 20 deletions
diff --git a/parse.c b/parse.c
index 6191ceaf..b0717f8c 100644
--- a/parse.c
+++ b/parse.c
@@ -2028,12 +2028,8 @@ ast_t *parse_enum_def(parse_ctx_t *ctx, const char *pos) {
if (!match(&pos, "(")) return NULL;
tag_ast_t *tags = NULL;
- int64_t next_value = 0;
-
whitespace(&pos);
for (;;) {
- const char *tag_start = pos;
-
spaces(&pos);
const char *tag_name = get_id(&pos);
if (!tag_name) break;
@@ -2055,22 +2051,7 @@ ast_t *parse_enum_def(parse_ctx_t *ctx, const char *pos) {
fields = NULL;
}
- spaces(&pos);
- if (match(&pos, "=")) {
- ast_t *val = expect(ctx, tag_start, &pos, parse_int, "I expected an integer literal after this '='");
- Int_t i = Int$from_text(Text$from_str(Match(val, Int)->str), NULL);
- // TODO check for overflow
- next_value = (i.small >> 2);
- }
-
- // Check for duplicate values:
- for (tag_ast_t *t = tags; t; t = t->next) {
- if (t->value == next_value)
- parser_err(ctx, tag_start, pos, "This tag value (%ld) is a duplicate of an earlier tag value", next_value);
- }
-
- tags = new(tag_ast_t, .name=tag_name, .value=next_value, .fields=fields, .secret=secret, .next=tags);
- ++next_value;
+ tags = new(tag_ast_t, .name=tag_name, .fields=fields, .secret=secret, .next=tags);
if (!match_separator(&pos))
break;