aboutsummaryrefslogtreecommitdiff
path: root/src/parse/containers.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-06 14:47:45 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-06 14:47:45 -0400
commita8316252db95e3d77f9f0e9beb89cfcb4573d5b1 (patch)
treee5905bce9611e35ccb2f84481232fca0e657ff42 /src/parse/containers.c
parenta0ac652cd1eebdc42425b34f1685f8cb20cb4eea (diff)
parent73246764f88f6f652316ee0c138a990d836698a7 (diff)
Merge branch 'main' into simplified-quotes
Diffstat (limited to 'src/parse/containers.c')
-rw-r--r--src/parse/containers.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/parse/containers.c b/src/parse/containers.c
index 821cbdd4..73d30ecd 100644
--- a/src/parse/containers.c
+++ b/src/parse/containers.c
@@ -16,7 +16,7 @@ ast_t *parse_list(parse_ctx_t *ctx, const char *pos) {
const char *start = pos;
if (!match(&pos, "[")) return NULL;
- whitespace(&pos);
+ whitespace(ctx, &pos);
ast_list_t *items = NULL;
for (;;) {
@@ -29,9 +29,9 @@ ast_t *parse_list(parse_ctx_t *ctx, const char *pos) {
suffixed = parse_comprehension_suffix(ctx, item);
}
items = new (ast_list_t, .ast = item, .next = items);
- if (!match_separator(&pos)) break;
+ if (!match_separator(ctx, &pos)) break;
}
- whitespace(&pos);
+ whitespace(ctx, &pos);
expect_closing(ctx, &pos, "]", "I wasn't able to parse the rest of this list");
REVERSE_LIST(items);
@@ -42,14 +42,14 @@ ast_t *parse_table(parse_ctx_t *ctx, const char *pos) {
const char *start = pos;
if (!match(&pos, "{")) return NULL;
- whitespace(&pos);
+ whitespace(ctx, &pos);
ast_list_t *entries = NULL;
for (;;) {
const char *entry_start = pos;
ast_t *key = optional(ctx, &pos, parse_extended_expr);
if (!key) break;
- whitespace(&pos);
+ whitespace(ctx, &pos);
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);
@@ -60,37 +60,37 @@ ast_t *parse_table(parse_ctx_t *ctx, const char *pos) {
suffixed = parse_comprehension_suffix(ctx, entry);
}
entries = new (ast_list_t, .ast = entry, .next = entries);
- if (!match_separator(&pos)) break;
+ if (!match_separator(ctx, &pos)) break;
}
REVERSE_LIST(entries);
- whitespace(&pos);
+ whitespace(ctx, &pos);
ast_t *fallback = NULL, *default_value = NULL;
if (match(&pos, ";")) {
for (;;) {
- whitespace(&pos);
+ whitespace(ctx, &pos);
const char *attr_start = pos;
if (match_word(&pos, "fallback")) {
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!match(&pos, "=")) parser_err(ctx, attr_start, pos, "I expected an '=' after 'fallback'");
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_word(&pos, "default")) {
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!match(&pos, "=")) parser_err(ctx, attr_start, pos, "I expected an '=' after 'default'");
if (default_value) parser_err(ctx, attr_start, pos, "This table already has a default");
default_value = expect(ctx, attr_start, &pos, parse_expr, "I expected a default value");
} else {
break;
}
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!match(&pos, ",")) break;
}
}
- whitespace(&pos);
+ whitespace(ctx, &pos);
expect_closing(ctx, &pos, "}", "I wasn't able to parse the rest of this table");
return NewAST(ctx->file, start, pos, Table, .default_value = default_value, .entries = entries,
@@ -102,13 +102,13 @@ ast_t *parse_set(parse_ctx_t *ctx, const char *pos) {
if (match(&pos, "||")) return NewAST(ctx->file, start, pos, Set);
if (!match(&pos, "|")) return NULL;
- whitespace(&pos);
+ whitespace(ctx, &pos);
ast_list_t *items = NULL;
for (;;) {
ast_t *item = optional(ctx, &pos, parse_extended_expr);
if (!item) break;
- whitespace(&pos);
+ whitespace(ctx, &pos);
ast_t *suffixed = parse_comprehension_suffix(ctx, item);
while (suffixed) {
item = suffixed;
@@ -116,12 +116,12 @@ ast_t *parse_set(parse_ctx_t *ctx, const char *pos) {
suffixed = parse_comprehension_suffix(ctx, item);
}
items = new (ast_list_t, .ast = item, .next = items);
- if (!match_separator(&pos)) break;
+ if (!match_separator(ctx, &pos)) break;
}
REVERSE_LIST(items);
- whitespace(&pos);
+ whitespace(ctx, &pos);
expect_closing(ctx, &pos, "|", "I wasn't able to parse the rest of this set");
return NewAST(ctx->file, start, pos, Set, .items = items);