aboutsummaryrefslogtreecommitdiff
path: root/src/parse/suffixes.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-25 12:12:02 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-25 12:12:02 -0400
commit55479cbf9e4a8f36afe41d84df687f05fc7661f0 (patch)
tree0bb00769f319716b75f5e0a3b0e73934de89aa88 /src/parse/suffixes.c
parentc3bcb504a07823ec8a096d34d0f4fe8dc5b27196 (diff)
Initial work to pass metadata for code
Diffstat (limited to 'src/parse/suffixes.c')
-rw-r--r--src/parse/suffixes.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/parse/suffixes.c b/src/parse/suffixes.c
index 7e748caf..58d951c4 100644
--- a/src/parse/suffixes.c
+++ b/src/parse/suffixes.c
@@ -14,10 +14,10 @@
ast_t *parse_field_suffix(parse_ctx_t *ctx, ast_t *lhs) {
if (!lhs) return NULL;
const char *pos = lhs->end;
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!match(&pos, ".")) return NULL;
if (*pos == '.') return NULL;
- whitespace(&pos);
+ whitespace(ctx, &pos);
bool dollar = match(&pos, "$");
const char *field = get_id(&pos);
if (!field) return NULL;
@@ -44,9 +44,9 @@ ast_t *parse_index_suffix(parse_ctx_t *ctx, ast_t *lhs) {
const char *start = lhs->start;
const char *pos = lhs->end;
if (!match(&pos, "[")) return NULL;
- whitespace(&pos);
+ whitespace(ctx, &pos);
ast_t *index = optional(ctx, &pos, parse_extended_expr);
- whitespace(&pos);
+ whitespace(ctx, &pos);
bool unchecked = match(&pos, ";") && (spaces(&pos), match_word(&pos, "unchecked") != 0);
expect_closing(ctx, &pos, "]", "I wasn't able to parse the rest of this index");
return NewAST(ctx->file, start, pos, Index, .indexed = lhs, .index = index, .unchecked = unchecked);
@@ -57,7 +57,7 @@ ast_t *parse_comprehension_suffix(parse_ctx_t *ctx, ast_t *expr) {
if (!expr) return NULL;
const char *start = expr->start;
const char *pos = expr->end;
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!match_word(&pos, "for")) return NULL;
ast_list_t *vars = NULL;
@@ -73,7 +73,7 @@ ast_t *parse_comprehension_suffix(parse_ctx_t *ctx, ast_t *expr) {
expect_str(ctx, start, &pos, "in", "I expected an 'in' for this 'for'");
ast_t *iter = expect(ctx, start, &pos, parse_expr, "I expected an iterable value for this 'for'");
const char *next_pos = pos;
- whitespace(&next_pos);
+ whitespace(ctx, &next_pos);
ast_t *filter = NULL;
if (match_word(&next_pos, "if")) {
pos = next_pos;
@@ -115,13 +115,13 @@ ast_t *parse_method_call_suffix(parse_ctx_t *ctx, ast_t *self) {
if (!fn) return NULL;
spaces(&pos);
if (!match(&pos, "(")) return NULL;
- whitespace(&pos);
+ whitespace(ctx, &pos);
arg_ast_t *args = NULL;
for (;;) {
const char *arg_start = pos;
const char *name = get_id(&pos);
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!name || !match(&pos, "=")) {
name = NULL;
pos = arg_start;
@@ -133,11 +133,11 @@ ast_t *parse_method_call_suffix(parse_ctx_t *ctx, ast_t *self) {
break;
}
args = new (arg_ast_t, .name = name, .value = arg, .next = args);
- if (!match_separator(&pos)) break;
+ if (!match_separator(ctx, &pos)) break;
}
REVERSE_LIST(args);
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!match(&pos, ")")) parser_err(ctx, start, pos, "This parenthesis is unclosed");
@@ -152,13 +152,13 @@ ast_t *parse_fncall_suffix(parse_ctx_t *ctx, ast_t *fn) {
if (!match(&pos, "(")) return NULL;
- whitespace(&pos);
+ whitespace(ctx, &pos);
arg_ast_t *args = NULL;
for (;;) {
const char *arg_start = pos;
const char *name = get_id(&pos);
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!name || !match(&pos, "=")) {
name = NULL;
pos = arg_start;
@@ -170,10 +170,10 @@ ast_t *parse_fncall_suffix(parse_ctx_t *ctx, ast_t *fn) {
break;
}
args = new (arg_ast_t, .name = name, .value = arg, .next = args);
- if (!match_separator(&pos)) break;
+ if (!match_separator(ctx, &pos)) break;
}
- whitespace(&pos);
+ whitespace(ctx, &pos);
if (!match(&pos, ")")) parser_err(ctx, start, pos, "This parenthesis is unclosed");