From 74eafbd39c4c622ce2ebdf699102ec7541dfe807 Mon Sep 17 00:00:00 2001 From: Cori Barker Date: Mon, 19 Jan 2026 09:36:05 +0000 Subject: parser --- include/parser/ast_node.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 include/parser/ast_node.h (limited to 'include/parser/ast_node.h') diff --git a/include/parser/ast_node.h b/include/parser/ast_node.h new file mode 100644 index 0000000..710054d --- /dev/null +++ b/include/parser/ast_node.h @@ -0,0 +1,70 @@ +#ifndef AST_NODE_H +#define AST_NODE_H + +#include "parser/node_type.h" + +#include +#include +#include + +class ASTNode { +public: + int line; + int column; + + virtual ~ASTNode() = default; +}; + +class Program : public ASTNode { +public: + std::vector> declarations; +}; + +class Declaration : public ASTNode { +public: + std::string type; + std::string var_name; + std::unique_ptr value; + + Declaration(std::string type, std::string var_name, std::unique_ptr value = nullptr) : type(type), var_name(var_name), value(std::move(value)) {} +}; + +class Assignment : public ASTNode { +public: + std::string variable_name; + std::unique_ptr value; + + Assignment(std::string var, std::unique_ptr 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 left; + std::string value; + std::unique_ptr right; + + BinaryOp(std::unique_ptr left, std::string value, std::unique_ptr right) : left(std::move(left)), value(std::move(value)), right(std::move(right)) {} +}; + +#endif -- cgit v1.2.3