ready to build AST

This commit is contained in:
2024-08-08 13:05:56 +00:00
parent f1eb6abcc1
commit 9900d5aaf3
23 changed files with 683 additions and 110 deletions

View File

@ -0,0 +1,27 @@
#ifndef STRUCTURAL_ASTNODE_H
#define STRUCTURAL_ASTNODE_H
#include <memory>
#include <variant>
#include <vector>
#include "astnode.h"
#include "expr_astnode.h"
#include "statement_astnode.h"
class FuncDef_ASTNode : public ASTNodeBase {
IdentifierType func_name;
std::vector<std::pair<IdentifierType, ExprTypeInfo>> params;
std::shared_ptr<SuiteStatement_ASTNode> func_body;
};
class Constructor_ASTNode : public FuncDef_ASTNode {};
class ClassVariable_ASTNode : public DefinitionStatement_ASTNode {};
class ClassDef_ASTNode : public ASTNodeBase {
private:
using ClassElement = std::variant<std::shared_ptr<Constructor_ASTNode>, std::shared_ptr<ClassVariable_ASTNode>,
std::shared_ptr<FuncDef_ASTNode>>;
std::vector<ClassElement> elements;
};
class Program_ASTNode : public ASTNodeBase {
using ProgramElement = std::variant<std::shared_ptr<FuncDef_ASTNode>, std::shared_ptr<ClassDef_ASTNode>,
std::shared_ptr<DefinitionStatement_ASTNode>>;
std::vector<ProgramElement> elements;
};
#endif