修复EOF飘逸(去除末尾\n)以及其他修复...

This commit is contained in:
2026-02-18 00:16:59 +08:00
parent 663fe39070
commit c81da16dfb
18 changed files with 404 additions and 65 deletions

View File

@@ -19,10 +19,17 @@ namespace Fig
Expr, // 表达式
Stmt, // 语句
/* Expressions */
IdentiExpr, // 标识符表达式
LiteralExpr, // 字面量表达式
PrefixExpr, // 一元 前缀表达式
InfixExpr, // 二元 中缀表达式
IndexExpr, // 后缀表达式,索引
CallExpr, // 后缀表达式,函数调用
/* Statements */
VarDecl,
};
struct AstNode
{
@@ -42,10 +49,28 @@ namespace Fig
struct Stmt : public AstNode
{
bool isPublic;
Stmt()
{
type = AstType::Stmt;
}
};
}; // namespace Fig
}; // namespace Fig
namespace std
{
template <>
struct std::formatter<Fig::AstNode *, char>
{
constexpr auto parse(std::format_parse_context &ctx)
{
return ctx.begin();
}
template <typename FormatContext>
auto format(const Fig::AstNode *_node, FormatContext &ctx) const
{
return std::format_to(ctx.out(), "{}", _node->toString().toStdString());
}
};
};