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
+36
View File
@@ -0,0 +1,36 @@
/*!
@file src/Ast/TypeExpr.hpp
@brief TypeExpr定义
@author PuqiAR (im@puqiar.top)
@date 2026-02-25
*/
#pragma once
#include <Ast/Base.hpp>
namespace Fig
{
struct NamedTypeExpr final : public TypeExpr
{
DynArray<String> path; // {"std", "file"} etc.
NamedTypeExpr()
{
type = AstType::NamedTypeExpr;
}
NamedTypeExpr(DynArray<String> _path, SourceLocation _location) :
path(std::move(_path))
{
type = AstType::NamedTypeExpr;
location = std::move(_location);
}
virtual String toString() const override
{
return std::format("<NamedTypeExpr '{}'>", path);
}
};
};