preliminary work on the loop parsing

This commit is contained in:
Lorenzo Torres 2025-12-01 22:32:41 +01:00
parent 39c92585f1
commit eaebcd7bdd
4 changed files with 18 additions and 2 deletions

View file

@ -262,8 +262,13 @@ static bool parse_special(lexer *l)
l->index += 1; l->index += 1;
return true; return true;
case '.': case '.':
add_token(l, TOKEN_DOT, 1); if (l->source[l->index+1] == '.') {
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; return true;
case ',': case ',':
add_token(l, TOKEN_COMMA, 1); add_token(l, TOKEN_COMMA, 1);

View file

@ -41,6 +41,7 @@ typedef enum {
TOKEN_COLON, // : TOKEN_COLON, // :
TOKEN_SEMICOLON, // ; TOKEN_SEMICOLON, // ;
TOKEN_DOT, // . TOKEN_DOT, // .
TOKEN_DOUBLE_DOT, // ..
TOKEN_BANG, // ! TOKEN_BANG, // !
TOKEN_COMMA, // , TOKEN_COMMA, // ,
TOKEN_LPAREN, // ( TOKEN_LPAREN, // (

View file

@ -373,6 +373,11 @@ ast_node *parse_expression(parser *p)
return left; return left;
} }
static ast_node *parse_for(parser *p)
{
return NULL;
}
static ast_node *parse_statement(parser *p) static ast_node *parse_statement(parser *p)
{ {
if (match(p, TOKEN_BREAK)) { if (match(p, TOKEN_BREAK)) {

View file

@ -151,6 +151,11 @@ typedef struct _ast_node {
/* This should be an access. */ /* This should be an access. */
struct _ast_node *path; struct _ast_node *path;
} import; } import;
struct {
struct _ast_node *parameters;
struct _ast_node *captures;
usize param_len;
} fr; // for
} expr; } expr;
} ast_node; } ast_node;