summaryrefslogtreecommitdiff
path: root/src/parser/parser_stmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/parser_stmt.c')
-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);