feat: 添加函数定义和类型表达式支持,重构解析器以处理新语法(函数定义)

This commit is contained in:
2026-02-26 14:41:41 +08:00
parent 12dc31a6c0
commit bb23ddf9fa
9 changed files with 376 additions and 11 deletions

View File

@@ -38,6 +38,12 @@ namespace Fig
IfStmt, // If语句
ElseIfStmt, // ElseIf语句不准悬空平铺式else if
WhileStmt, // while语句
FnDefStmt, // func函数定义语句
/* Type Expressions */
TypeExpr, // 基类
NamedTypeExpr, // 命名类型支持namespace, std.file这样的
// 泛型等...
};
struct AstNode
{
@@ -45,7 +51,16 @@ namespace Fig
SourceLocation location;
virtual String toString() const = 0;
virtual ~AstNode(){};
virtual ~AstNode() {};
};
struct TypeExpr : public AstNode
{
TypeExpr()
{
type = AstType::TypeExpr;
}
virtual ~TypeExpr() = default;
};
struct Program;