feat(frontend): 命令行添加IR和AST选择输出
This commit is contained in:
@@ -3,3 +3,27 @@
|
||||
// - 表达式、语句、声明、函数、类型等节点
|
||||
// - 支持后续阶段在节点上附加信息(类型、符号绑定、常量值等)
|
||||
#include "ast/AstNodes.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ast {
|
||||
|
||||
NumberExpr::NumberExpr(int v) : value(v) {}
|
||||
|
||||
VarExpr::VarExpr(std::string n) : name(std::move(n)) {}
|
||||
|
||||
BinaryExpr::BinaryExpr(BinaryOp op, std::shared_ptr<Expr> lhs,
|
||||
std::shared_ptr<Expr> rhs)
|
||||
: op(op), lhs(std::move(lhs)), rhs(std::move(rhs)) {}
|
||||
|
||||
ReturnStmt::ReturnStmt(std::shared_ptr<Expr> v) : value(std::move(v)) {}
|
||||
|
||||
VarDecl::VarDecl(std::string n, std::shared_ptr<Expr> i)
|
||||
: name(std::move(n)), init(std::move(i)) {}
|
||||
|
||||
FuncDef::FuncDef(std::string n, std::shared_ptr<Block> b)
|
||||
: name(std::move(n)), body(std::move(b)) {}
|
||||
|
||||
CompUnit::CompUnit(std::shared_ptr<FuncDef> f) : func(std::move(f)) {}
|
||||
|
||||
} // namespace ast
|
||||
|
||||
Reference in New Issue
Block a user