commit 2db3f9c4a41b9f00e1f02ab71206edd808630fdf
parent 5b7a885ffaca4b60eb8e313952b182de9506e437
Author: citbl <citbl@citbl.org>
Date: Tue, 25 Nov 2025 23:41:06 +1000
wip
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/parser/stmt.c b/src/parser/stmt.c
@@ -51,7 +51,7 @@ parse_while(Parser* par)
Node*
parse_for(Parser* par)
{
- expect(par, TOKEN_FOR);
+ Token for_token = expect(par, TOKEN_FOR);
expect(par, TOKEN_LPAREN);
// init can be empty, a decl, or a expr statement
@@ -80,6 +80,9 @@ parse_for(Parser* par)
Node* node = (Node*)calloc(1, sizeof(Node));
node->type = NODE_FOR;
node->scope = NULL;
+ node->line = for_token.line;
+ node->col = for_token.col;
+ node->filename = par->filename;
node->data.for_statement.init = init;
node->data.for_statement.cond = cond;
node->data.for_statement.increment = inc;
diff --git a/tests/ex-for-simple2.ox b/tests/ex-for-simple2.ox
@@ -1,7 +1,9 @@
void main() {
~int x;
+ print("initial value:");
print(x);
- for(; x < 5; x++) {
+ for(int x = 3; x < 5; x++) {
+ //TODO the x defined in the for init is never actually used
print(x);
print("bozo!");
}