From eaebcd7bdd4d82dac301f0c81679d205f64604e5 Mon Sep 17 00:00:00 2001 From: Lorenzo Torres Date: Mon, 1 Dec 2025 22:32:41 +0100 Subject: [PATCH] preliminary work on the `loop` parsing --- lexer.c | 9 +++++++-- lexer.h | 1 + parser.c | 5 +++++ parser.h | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lexer.c b/lexer.c index 266001b..6167bfa 100644 --- a/lexer.c +++ b/lexer.c @@ -262,8 +262,13 @@ static bool parse_special(lexer *l) l->index += 1; return true; case '.': - add_token(l, TOKEN_DOT, 1); - l->index += 1; + if (l->source[l->index+1] == '.') { + add_token(l, TOKEN_DOUBLE_DOT, 2); + l->index += 2; + } else { + add_token(l, TOKEN_DOT, 1); + l->index += 1; + } return true; case ',': add_token(l, TOKEN_COMMA, 1); diff --git a/lexer.h b/lexer.h index 28b11e3..c0f071c 100644 --- a/lexer.h +++ b/lexer.h @@ -41,6 +41,7 @@ typedef enum { TOKEN_COLON, // : TOKEN_SEMICOLON, // ; TOKEN_DOT, // . + TOKEN_DOUBLE_DOT, // .. TOKEN_BANG, // ! TOKEN_COMMA, // , TOKEN_LPAREN, // ( diff --git a/parser.c b/parser.c index a827fb5..c20c4cb 100644 --- a/parser.c +++ b/parser.c @@ -373,6 +373,11 @@ ast_node *parse_expression(parser *p) return left; } +static ast_node *parse_for(parser *p) +{ + return NULL; +} + static ast_node *parse_statement(parser *p) { if (match(p, TOKEN_BREAK)) { diff --git a/parser.h b/parser.h index 8946621..3933402 100644 --- a/parser.h +++ b/parser.h @@ -151,6 +151,11 @@ typedef struct _ast_node { /* This should be an access. */ struct _ast_node *path; } import; + struct { + struct _ast_node *parameters; + struct _ast_node *captures; + usize param_len; + } fr; // for } expr; } ast_node;