aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-24 15:24:44 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-24 15:24:44 -0500
commit106704b9564b50e95dfce50b7a7471e73b64a78e (patch)
tree509e94ff49f76c9c2edc75c20fe1da9bfd600912 /parse.c
parentc7470346457550467bafd9199185c5d0e8481f02 (diff)
Improve enums with metamethods
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index bbdb5f31..685461da 100644
--- a/parse.c
+++ b/parse.c
@@ -1514,10 +1514,16 @@ ast_t *parse_enum_def(parse_ctx_t *ctx, const char *pos) {
spaces(&pos);
arg_ast_t *fields;
+ bool secret = false;
if (match(&pos, "(")) {
whitespace(&pos);
fields = parse_args(ctx, &pos, false);
whitespace(&pos);
+ if (match(&pos, ";")) { // Extra flags
+ whitespace(&pos);
+ secret = match_word(&pos, "secret");
+ whitespace(&pos);
+ }
expect_closing(ctx, &pos, ")", "I wasn't able to parse the rest of this tagged union member");
} else {
fields = NULL;
@@ -1535,7 +1541,7 @@ ast_t *parse_enum_def(parse_ctx_t *ctx, const char *pos) {
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, .next=tags);
+ tags = new(tag_ast_t, .name=tag_name, .value=next_value, .fields=fields, .secret=secret, .next=tags);
++next_value;
if (!match_separator(&pos))