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,42 @@
#ifndef STATEMENT_ASTNODE_H
#define STATEMENT_ASTNODE_H
#include <vector>
#include "astnode.h"
#include "expr_astnode.h"
class Statement_ASTNode : public ASTNodeBase {
public:
virtual ~Statement_ASTNode() = default;
};
class EmptyStatement_ASTNode : public Statement_ASTNode {};
class DefinitionStatement_ASTNode : public Statement_ASTNode {
ExprTypeInfo type;
std::vector<std::pair<IdentifierType, std::shared_ptr<Expr_ASTNode>>> vars;
};
class ExprStatement_ASTNode : public Statement_ASTNode {
std::shared_ptr<Expr_ASTNode> expr;
};
class IfStatement_ASTNode : public Statement_ASTNode {
bool has_else_clause;
std::shared_ptr<Expr_ASTNode> condition;
std::shared_ptr<Statement_ASTNode> if_clause;
std::shared_ptr<Statement_ASTNode> else_clause;
};
class WhileStatement_ASTNode : public Statement_ASTNode {
std::shared_ptr<Expr_ASTNode> condition;
std::shared_ptr<Statement_ASTNode> loop_body;
};
class ForStatement_ASTNode : public Statement_ASTNode {
std::shared_ptr<Statement_ASTNode> initial;
std::shared_ptr<Expr_ASTNode> condition;
std::shared_ptr<Statement_ASTNode> update;
std::shared_ptr<Statement_ASTNode> loop_body;
};
class JmpStatement_ASTNode : public Statement_ASTNode {
std::shared_ptr<Expr_ASTNode> return_value;
};
class SuiteStatement_ASTNode : public Statement_ASTNode {
std::vector<std::shared_ptr<Statement_ASTNode>> statements;
};
#endif // STATEMENT_ASTNODE_H