feat: for..in 范围语法 .. 改为 to 关键字
This commit is contained in:
+3
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user