aboutsummaryrefslogtreecommitdiff
path: root/include/cps/AST.h
diff options
context:
space:
mode:
authorov-4 <hausemasterstream@gmail.com>2026-01-29 10:20:58 +0000
committerov-4 <hausemasterstream@gmail.com>2026-01-29 10:20:58 +0000
commitc2a3cecc1ab2d3f27dcea40a6f0f353b0306d66a (patch)
tree3adfa6ed51620adcf6b129eade1622b01527c8a9 /include/cps/AST.h
parent3f48a1d3af588242cd745e344b6b0b02cfb26131 (diff)
Added INPUT, OUTPUT and DECLARE
Diffstat (limited to 'include/cps/AST.h')
-rw-r--r--include/cps/AST.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/include/cps/AST.h b/include/cps/AST.h
new file mode 100644
index 0000000..5b28e8a
--- /dev/null
+++ b/include/cps/AST.h
@@ -0,0 +1,63 @@
+#pragma once
+#include <string>
+#include <memory>
+#include <vector>
+
+namespace cps {
+
+class ExprAST {
+public:
+ virtual ~ExprAST() = default;
+};
+
+class NumberExprAST : public ExprAST {
+ int Val;
+public:
+ NumberExprAST(int Val) : Val(Val) {}
+ int getVal() const { return Val; }
+};
+
+class VariableExprAST : public ExprAST {
+ std::string Name;
+public:
+ VariableExprAST(const std::string &Name) : Name(Name) {}
+ const std::string &getName() const { return Name; }
+};
+
+class StmtAST {
+public:
+ virtual ~StmtAST() = default;
+};
+
+class DeclareStmtAST : public StmtAST {
+ std::string Name;
+public:
+ DeclareStmtAST(const std::string &Name) : Name(Name) {}
+ const std::string &getName() const { return Name; }
+};
+
+class AssignStmtAST : public StmtAST {
+ std::string Name;
+ std::unique_ptr<ExprAST> Expr;
+public:
+ AssignStmtAST(const std::string &Name, std::unique_ptr<ExprAST> Expr)
+ : Name(Name), Expr(std::move(Expr)) {}
+ const std::string &getName() const { return Name; }
+ ExprAST *getExpr() const { return Expr.get(); }
+};
+
+class InputStmtAST : public StmtAST {
+ std::string Name;
+public:
+ InputStmtAST(const std::string &Name) : Name(Name) {}
+ const std::string &getName() const { return Name; }
+};
+
+class OutputStmtAST : public StmtAST {
+ std::unique_ptr<ExprAST> Expr;
+public:
+ OutputStmtAST(std::unique_ptr<ExprAST> Expr) : Expr(std::move(Expr)) {}
+ ExprAST *getExpr() const { return Expr.get(); }
+};
+
+} // namespace cps