完成表达式Ast定义。修改了format文件
This commit is contained in:
50
src/Ast/Base.hpp
Normal file
50
src/Ast/Base.hpp
Normal 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
|
||||
Reference in New Issue
Block a user