set up semantic visitor

This commit is contained in:
2024-08-13 14:03:23 +00:00
parent b010326e60
commit 1ba056f0ac
12 changed files with 661 additions and 62 deletions

View File

@ -4,10 +4,12 @@
#include <variant>
#include <vector>
#include "astnode.h"
#include "expr_astnode.h"
#include "statement_astnode.h"
class FuncDef_ASTNode : public ASTNodeBase {
friend Visitor;
friend class ASTSemanticCheckVisitor;
bool is_constructor;
IdentifierType func_name;
ExprTypeInfo return_type;
@ -16,26 +18,33 @@ class FuncDef_ASTNode : public ASTNodeBase {
public:
FuncDef_ASTNode() = default;
virtual void accept(class ASTNodeVisitorBase *visitor) override;
};
class ClassDef_ASTNode : public ASTNodeBase {
friend Visitor;
friend class ASTSemanticCheckVisitor;
private:
std::string class_name;
std::vector<std::shared_ptr<DefinitionStatement_ASTNode>> member_variables;
std::vector<std::shared_ptr<FuncDef_ASTNode>> member_functions;
std::shared_ptr<FuncDef_ASTNode> constructor;
std::vector<std::shared_ptr<ASTNodeBase>> sorted_children;
public:
ClassDef_ASTNode() = default;
virtual void accept(class ASTNodeVisitorBase *visitor) override;
};
class Program_ASTNode : public ASTNodeBase {
friend Visitor;
friend class ASTSemanticCheckVisitor;
std::vector<std::shared_ptr<DefinitionStatement_ASTNode>> global_variables;
std::vector<std::shared_ptr<ClassDef_ASTNode>> classes;
std::vector<std::shared_ptr<FuncDef_ASTNode>> functions;
std::vector<std::shared_ptr<ASTNodeBase>> sorted_children;
public:
Program_ASTNode() = default;
virtual void accept(class ASTNodeVisitorBase *visitor) override;
};
#endif