summaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-13 00:09:48 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-13 00:09:48 +0000
commit7d67cf922c506ad1ba443e96ffcc46810f90478c (patch)
tree12608bafe8222f909f7ad9220b5424376747ab41 /src/parser
parent4a427b6acf8fcc7ee8d1318faabf147d29d3a866 (diff)
Recursive blocks should be supported now.
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/parser_stmt.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/parser/parser_stmt.c b/src/parser/parser_stmt.c
index b5aa549..8a89cc7 100644
--- a/src/parser/parser_stmt.c
+++ b/src/parser/parser_stmt.c
@@ -2150,6 +2150,44 @@ ASTNode *parse_statement(ParserContext *ctx, Lexer *l)
{
return parse_test(ctx, l);
}
+ if (tk.type == TOK_COMPTIME)
+ {
+ char *src = run_comptime_block(ctx, l);
+ Lexer new_l;
+ lexer_init(&new_l, src);
+ ASTNode *head = NULL, *tail = NULL;
+
+ while (lexer_peek(&new_l).type != TOK_EOF)
+ {
+ ASTNode *s = parse_statement(ctx, &new_l);
+ if (!s)
+ {
+ break;
+ }
+ if (!head)
+ {
+ head = s;
+ }
+ else
+ {
+ tail->next = s;
+ }
+ tail = s;
+ while (tail->next)
+ {
+ tail = tail->next;
+ }
+ }
+
+ if (head && !head->next)
+ {
+ return head;
+ }
+
+ ASTNode *b = ast_create(NODE_BLOCK);
+ b->block.statements = head;
+ return b;
+ }
if (tk.type == TOK_ASSERT)
{
return parse_assert(ctx, l);