feat: 类型别名 type alias (P1 #10)
- lexer: TOK_TYPE 关键字 - ast: AST_TYPE_ALIAS + AST_PROGRAM aliases数组 - parser: parse_type_expr() 抽取, type Name = Type; 解析 - sema: 别名注册+解析, 类型标注/struct字段/函数参数均支持 - 新增测试: 15_type_alias.l, 16_type_alias_struct.l 测试: 112 通过 (41+15+41+15)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
type Meters = i64;
|
||||
fn main() -> i64 {
|
||||
let x: Meters = 100;
|
||||
print_i64(x);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
struct Point { x: i64, y: i64 }
|
||||
type P = Point;
|
||||
fn main() -> i64 {
|
||||
let p: P = Point { x: 10, y: 20 };
|
||||
print_i64(p.x);
|
||||
print_i64(p.y);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user