diff --git a/CMakeLists.txt b/CMakeLists.txt index 2883aff..7572aed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,7 @@ SET(SCULLY_SOURCE src/AST/IfStatement.cpp src/AST/ParameterList.cpp src/AST/ReturnStatement.cpp + src/AST/RandomForStatement.cpp src/AST/RandomIfStatement.cpp src/AST/Scope.cpp src/AST/Statement.cpp diff --git a/inc/AST/ASTVisitor.h b/inc/AST/ASTVisitor.h index 8d539f7..6421a2b 100644 --- a/inc/AST/ASTVisitor.h +++ b/inc/AST/ASTVisitor.h @@ -10,6 +10,7 @@ #include "FunctionDefinition.h" #include "IfStatement.h" #include "ParameterList.h" +#include "RandomForStatement.h" #include "RandomIfStatement.h" #include "ReturnStatement.h" #include "Scope.h" @@ -32,6 +33,7 @@ public: virtual void visit(FunctionDefinition* e) = 0; virtual void visit(IfStatement* e) = 0; virtual void visit(ParameterList* e) = 0; + virtual void visit(RandomForStatement* e) = 0; virtual void visit(RandomIfStatement* e) = 0; virtual void visit(ReturnStatement* e) = 0; virtual void visit(Scope* e) = 0; diff --git a/inc/AST/ForStatement.h b/inc/AST/ForStatement.h index 8b80cc7..a25beba 100644 --- a/inc/AST/ForStatement.h +++ b/inc/AST/ForStatement.h @@ -14,7 +14,7 @@ public: Expression* getInit(); Expression* getCond(); Expression* getStep(); - Statement* GetStmt(); + Statement* getStmt(); private: Expression* init_; Expression* cond_; diff --git a/inc/AST/RandomForStatement.h b/inc/AST/RandomForStatement.h new file mode 100644 index 0000000..0d508a5 --- /dev/null +++ b/inc/AST/RandomForStatement.h @@ -0,0 +1,26 @@ +#ifndef RANDOMFORSTATEMENT_H +#define RANDOMFORSTATEMENT_H + +#include "AST/Expression.h" +#include "AST/Statement.h" + +class RandomForStatement : public Statement +{ +public: + RandomForStatement(Expression* init, Expression* prob, Expression* step, Statement* stmt); + virtual ~RandomForStatement(); + + virtual void accept(ASTVisitor *visitor); + + Expression* getInit(); + Expression* getProb(); + Expression* getStep(); + Statement* getStmt(); +private: + Expression* init_; + Expression* prob_; + Expression* step_; + Statement* stmt_; +}; + +#endif // RANDOMFORSTATEMENT_H diff --git a/src/AST/ForStatement.cpp b/src/AST/ForStatement.cpp index 6618883..c64b637 100644 --- a/src/AST/ForStatement.cpp +++ b/src/AST/ForStatement.cpp @@ -25,6 +25,6 @@ Expression* ForStatement::getStep() { return step_; } -Statement* ForStatement::GetStmt() { +Statement* ForStatement::getStmt() { return stmt_; } diff --git a/src/AST/RandomForStatement.cpp b/src/AST/RandomForStatement.cpp new file mode 100644 index 0000000..e4b6172 --- /dev/null +++ b/src/AST/RandomForStatement.cpp @@ -0,0 +1,32 @@ +#include "AST/RandomForStatement.h" +#include "AST/ASTVisitor.h" + +RandomForStatement::RandomForStatement(Expression *init, Expression *prob, Expression *step, Statement *stmt) : init_(init),prob_(prob),step_(step),stmt_(stmt) +{ + // +} + +RandomForStatement::~RandomForStatement() { + // +} + +void RandomForStatement::accept(ASTVisitor *visitor) { + visitor->visit(this); +} + +Expression* RandomForStatement::getInit() { + return init_; +} + +Expression* RandomForStatement::getProb() { + return prob_; +} + +Expression* RandomForStatement::getStep() { + return step_; +} + +Statement* RandomForStatement::getStmt() { + return stmt_; +} +