diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-24 01:39:38 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-24 01:39:52 +0000 |
| commit | 3df7cada4c3d050a01980afffdbfc0fc60be0fb5 (patch) | |
| tree | aa1dd603039d284f58b62c89bb662fd74c19deda /src/parser/parser_expr.c | |
| parent | 769d8ff1a1fd898e1a8c8b299f7e7fa444f32528 (diff) | |
Fix for #106
Diffstat (limited to 'src/parser/parser_expr.c')
| -rw-r--r-- | src/parser/parser_expr.c | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/src/parser/parser_expr.c b/src/parser/parser_expr.c index c848072..1556ee7 100644 --- a/src/parser/parser_expr.c +++ b/src/parser/parser_expr.c @@ -3623,44 +3623,8 @@ ASTNode *parse_expr_prec(ParserContext *ctx, Lexer *l, Precedence min_prec) } else if (is_token(t, "sizeof")) { - lexer_next(l); - if (lexer_peek(l).type == TOK_LPAREN) - { - const char *start = l->src + l->pos; - int depth = 0; - while (1) - { - Token tk = lexer_peek(l); - if (tk.type == TOK_EOF) - { - zpanic_at(tk, "Unterminated sizeof"); - } - if (tk.type == TOK_LPAREN) - { - depth++; - } - if (tk.type == TOK_RPAREN) - { - depth--; - if (depth == 0) - { - lexer_next(l); - break; - } - } - lexer_next(l); - } - int len = (l->src + l->pos) - start; - char *content = xmalloc(len + 8); - sprintf(content, "sizeof%.*s", len, start); - lhs = ast_create(NODE_RAW_STMT); - lhs->raw_stmt.content = content; - lhs->type_info = type_new(TYPE_INT); - } - else - { - zpanic_at(lexer_peek(l), "sizeof must be followed by ("); - } + lexer_next(l); // consume sizeof + lhs = parse_sizeof_expr(ctx, l); } else { |
