From 943ed04b775949e8bc4948bcb8d762a32ab14f76 Mon Sep 17 00:00:00 2001 From: ov-4 Date: Thu, 29 Jan 2026 14:24:05 +0000 Subject: Added array --- include/cps/AST.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'include/cps/AST.h') diff --git a/include/cps/AST.h b/include/cps/AST.h index 1473c45..aaf81cb 100644 --- a/include/cps/AST.h +++ b/include/cps/AST.h @@ -24,6 +24,16 @@ public: const std::string &getName() const { return Name; } }; +class ArrayAccessExprAST : public ExprAST { + std::string Name; + std::vector> Indices; +public: + ArrayAccessExprAST(const std::string &Name, std::vector> Indices) + : Name(Name), Indices(std::move(Indices)) {} + const std::string &getName() const { return Name; } + const std::vector> &getIndices() const { return Indices; } +}; + class BinaryExprAST : public ExprAST { int Op; std::unique_ptr LHS, RHS; @@ -47,6 +57,21 @@ public: const std::string &getName() const { return Name; } }; +class ArrayDeclareStmtAST : public StmtAST { + std::string Name; + std::vector, std::unique_ptr>> Bounds; + std::string Type; +public: + ArrayDeclareStmtAST(const std::string &Name, + std::vector, std::unique_ptr>> Bounds, + const std::string &Type) + : Name(Name), Bounds(std::move(Bounds)), Type(Type) {} + + const std::string &getName() const { return Name; } + const std::vector, std::unique_ptr>> &getBounds() const { return Bounds; } + const std::string &getType() const { return Type; } +}; + class AssignStmtAST : public StmtAST { std::string Name; std::unique_ptr Expr; @@ -57,6 +82,18 @@ public: ExprAST *getExpr() const { return Expr.get(); } }; +class ArrayAssignStmtAST : public StmtAST { + std::string Name; + std::vector> Indices; + std::unique_ptr Expr; +public: + ArrayAssignStmtAST(const std::string &Name, std::vector> Indices, std::unique_ptr Expr) + : Name(Name), Indices(std::move(Indices)), Expr(std::move(Expr)) {} + const std::string &getName() const { return Name; } + const std::vector> &getIndices() const { return Indices; } + ExprAST *getExpr() const { return Expr.get(); } +}; + class InputStmtAST : public StmtAST { std::string Name; public: -- cgit v1.3.1-4-g156e