aboutsummaryrefslogtreecommitdiff
path: root/include/parser/ast_node.hpp
diff options
context:
space:
mode:
authorCori Barker <coribarker2@gmail.com>2026-02-09 11:59:14 +0000
committerCori Barker <coribarker2@gmail.com>2026-02-09 11:59:14 +0000
commitb3f83360282bfe327c0ccbeecab706e0e7d2c050 (patch)
tree1ab29e9ebbf3d3f2fb66f59cbbc687451f8da62e /include/parser/ast_node.hpp
parent26738e6c932038ea309a5dbaa9e941fc1ce144b8 (diff)
Changed .h to .hpp
Diffstat (limited to 'include/parser/ast_node.hpp')
-rw-r--r--include/parser/ast_node.hpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/include/parser/ast_node.hpp b/include/parser/ast_node.hpp
new file mode 100644
index 0000000..6539cf6
--- /dev/null
+++ b/include/parser/ast_node.hpp
@@ -0,0 +1,70 @@
+#ifndef AST_NODE_H
+#define AST_NODE_H
+
+#include "node_type.hpp"
+
+#include <string>
+#include <vector>
+#include <memory>
+
+class ASTNode {
+public:
+ int line;
+ int column;
+
+ virtual ~ASTNode() = default;
+};
+
+class Program : public ASTNode {
+public:
+ std::vector<std::unique_ptr<ASTNode>> declarations;
+};
+
+class Declaration : public ASTNode {
+public:
+ std::string type;
+ std::string var_name;
+ std::unique_ptr<ASTNode> value;
+
+ Declaration(std::string type, std::string var_name, std::unique_ptr<ASTNode> value = nullptr) : type(type), var_name(var_name), value(std::move(value)) {}
+};
+
+class Assignment : public ASTNode {
+public:
+ std::string variable_name;
+ std::unique_ptr<ASTNode> value;
+
+ Assignment(std::string var, std::unique_ptr<ASTNode> val) : variable_name(var), value(std::move(val)) {}
+};
+
+class NumberLiteral : public ASTNode {
+public:
+ double value;
+
+ NumberLiteral(double val) : value(val) {}
+};
+
+class StringLiteral : public ASTNode {
+public:
+ std::string value;
+
+ StringLiteral(std::string val) : value(val) {}
+};
+
+class Identifier : public ASTNode {
+public:
+ std::string name;
+
+ Identifier(std::string name) : name(name) {}
+};
+
+class BinaryOp : public ASTNode {
+public:
+ std::unique_ptr<ASTNode> left;
+ std::string value;
+ std::unique_ptr<ASTNode> right;
+
+ BinaryOp(std::unique_ptr<ASTNode> left, std::string value, std::unique_ptr<ASTNode> right) : left(std::move(left)), value(std::move(value)), right(std::move(right)) {}
+};
+
+#endif