feat: for..in 范围语法 .. 改为 to 关键字

This commit is contained in:
2026-06-05 19:44:26 +08:00
parent 9a256d9be1
commit a28d33854c
8 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -546,8 +546,8 @@ static AstNode* parse_statement(Parser* p, ErrorInfo* error) {
AstNode* start_expr = parse_expr(p, error);
if (!start_expr) return NULL;
// 解析 '..'
if (!expect(p, TOK_DOT_DOT, error, "缺少 '..'")) return NULL;
// 解析 'to'
if (!expect(p, TOK_TO, error, "缺少 'to'")) return NULL;
// 解析结束表达式
AstNode* end_expr = parse_expr(p, error);
@@ -557,7 +557,7 @@ static AstNode* parse_statement(Parser* p, ErrorInfo* error) {
AstNode* body = parse_block(p, error);
if (!body) return NULL;
// 脱糖: for i in start..end { body; }
// 脱糖: for i in start to end { body; }
// → { let mut i = start; while i < end { body; i = i + 1; } }
const char* vname = arena_strdup_impl(p->arena, var_name->start, var_name->length);