aboutsummaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/functions.c11
-rw-r--r--src/parse/suffixes.c2
2 files changed, 8 insertions, 5 deletions
diff --git a/src/parse/functions.c b/src/parse/functions.c
index e820182b..b50519b7 100644
--- a/src/parse/functions.c
+++ b/src/parse/functions.c
@@ -26,6 +26,7 @@ arg_ast_t *parse_args(parse_ctx_t *ctx, const char **pos) {
type_ast_t *type = NULL;
typedef struct name_list_s {
+ const char *start, *end;
const char *name;
struct name_list_s *next;
} name_list_t;
@@ -35,21 +36,22 @@ arg_ast_t *parse_args(parse_ctx_t *ctx, const char **pos) {
whitespace(ctx, pos);
const char *name = get_id(pos);
if (!name) break;
+ const char *name_start = *pos;
whitespace(ctx, pos);
if (match(pos, ":")) {
type = expect(ctx, *pos - 1, pos, parse_type, "I expected a type here");
- names = new (name_list_t, .name = name, .next = names);
whitespace(ctx, pos);
if (match(pos, "="))
default_val = expect(ctx, *pos - 1, pos, parse_term, "I expected a value after this '='");
+ names = new (name_list_t, .start = name_start, .end = *pos, .name = name, .next = names);
break;
} else if (strncmp(*pos, "==", 2) != 0 && match(pos, "=")) {
default_val = expect(ctx, *pos - 1, pos, parse_term, "I expected a value after this '='");
- names = new (name_list_t, .name = name, .next = names);
+ names = new (name_list_t, .start = name_start, .end = *pos, .name = name, .next = names);
break;
} else if (name) {
- names = new (name_list_t, .name = name, .next = names);
+ names = new (name_list_t, .start = name_start, .end = *pos, .name = name, .next = names);
spaces(pos);
if (!match(pos, ",")) break;
} else {
@@ -64,7 +66,8 @@ arg_ast_t *parse_args(parse_ctx_t *ctx, const char **pos) {
REVERSE_LIST(names);
for (; names; names = names->next)
- args = new (arg_ast_t, .name = names->name, .type = type, .value = default_val, .next = args);
+ args = new (arg_ast_t, .start = names->start, .end = names->end, .name = names->name, .type = type,
+ .value = default_val, .next = args);
if (!match_separator(ctx, pos)) break;
}
diff --git a/src/parse/suffixes.c b/src/parse/suffixes.c
index 58d951c4..cb54b2f6 100644
--- a/src/parse/suffixes.c
+++ b/src/parse/suffixes.c
@@ -132,7 +132,7 @@ 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);
+ 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);