diff options
Diffstat (limited to 'src/parse/suffixes.c')
| -rw-r--r-- | src/parse/suffixes.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/parse/suffixes.c b/src/parse/suffixes.c index 7e748caf..cb54b2f6 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; @@ -132,12 +132,12 @@ ast_t *parse_method_call_suffix(parse_ctx_t *ctx, ast_t *self) { if (name) parser_err(ctx, arg_start, pos, "I expected an argument here"); break; } - args = new (arg_ast_t, .name = name, .value = arg, .next = args); - if (!match_separator(&pos)) break; + args = new (arg_ast_t, .start = arg_start, .end = arg->end, .name = name, .value = arg, .next = args); + 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"); |
