完成表达式Ast定义。修改了format文件

This commit is contained in:
2026-02-14 18:00:46 +08:00
parent 51e831cc6a
commit 35e479fd05
8 changed files with 307 additions and 14 deletions

50
src/Ast/Base.hpp Normal file
View File

@@ -0,0 +1,50 @@
/*!
@file src/Ast/Base.hpp
@brief AstNode基类定义
@author PuqiAR (im@puqiar.top)
@date 2026-02-14
*/
#pragma once
#include <Core/SourceLocations.hpp>
#include <Deps/Deps.hpp>
#include <cstdint>
namespace Fig
{
enum class AstType : std::uint8_t
{
AstNode, // 基类
Expr, // 表达式
Stmt, // 语句
IdentiExpr, // 标识符表达式
LiteralExpr, // 字面量表达式
UnaryExpr, // 一元表达式
BinaryExpr, // 二元表达式
TernaryExpr, // 三元表达式
};
struct AstNode
{
AstType type = AstType::AstNode;
SourceLocation location;
};
struct Expr : public AstNode
{
Expr()
{
type = AstType::Expr;
}
};
struct Stmt : public AstNode
{
Stmt()
{
type = AstType::Stmt;
}
};
}; // namespace Fig