diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:29:48 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:29:48 -0400 |
| commit | 210179ee672a0c3799328a54e886f574b3823e3d (patch) | |
| tree | 25ddb95503c537c19b9fdb7614df2f16c4012d21 /parse.c | |
| parent | dee3742b48e27ef36637d004163286d3352b0763 (diff) | |
Optional enums (deprecated custom tag values)
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 21 |
1 files changed, 1 insertions, 20 deletions
@@ -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; |
