StatementList
This commit is contained in:
@@ -61,13 +61,14 @@ SET(SCULLY_SOURCE
|
|||||||
src/AST/ASTElement.cpp
|
src/AST/ASTElement.cpp
|
||||||
src/AST/ASTVisitor.cpp
|
src/AST/ASTVisitor.cpp
|
||||||
src/AST/AssignmentExpression.cpp
|
src/AST/AssignmentExpression.cpp
|
||||||
src/AST/BinOp.cpp
|
src/AST/BinOp.cpp
|
||||||
src/AST/ConstantExpression.cpp
|
src/AST/ConstantExpression.cpp
|
||||||
src/AST/Expression.cpp
|
src/AST/Expression.cpp
|
||||||
src/AST/ParameterList.cpp
|
src/AST/ParameterList.cpp
|
||||||
src/AST/Statement.cpp
|
src/AST/Statement.cpp
|
||||||
src/AST/Type.cpp
|
src/AST/Type.cpp
|
||||||
src/AST/VariableDefinition.cpp
|
src/AST/VariableDefinition.cpp
|
||||||
|
src/AST/StatementList.cpp
|
||||||
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/grammar.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "ConstantExpression.h"
|
#include "ConstantExpression.h"
|
||||||
#include "VariableDefinition.h"
|
#include "VariableDefinition.h"
|
||||||
#include "ParameterList.h"
|
#include "ParameterList.h"
|
||||||
|
#include "StatementList.h"
|
||||||
|
|
||||||
class ASTVisitor {
|
class ASTVisitor {
|
||||||
public:
|
public:
|
||||||
@@ -17,6 +18,7 @@ public:
|
|||||||
virtual void visit(ConstantExpression* e) = 0;
|
virtual void visit(ConstantExpression* e) = 0;
|
||||||
virtual void visit(ParameterList* e) = 0;
|
virtual void visit(ParameterList* e) = 0;
|
||||||
virtual void visit(VariableDefinition* e) = 0;
|
virtual void visit(VariableDefinition* e) = 0;
|
||||||
|
virtual void visit(StatementList* e) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ASTVISITOR_H
|
#endif // ASTVISITOR_H
|
||||||
|
|||||||
20
inc/AST/StatementList.h
Normal file
20
inc/AST/StatementList.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef STATEMENTLIST_H
|
||||||
|
#define STATEMENTLIST_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "AST/ASTElement.h"
|
||||||
|
#include "AST/Statement.h"
|
||||||
|
|
||||||
|
class StatementList : public ASTElement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StatementList();
|
||||||
|
virtual ~StatementList();
|
||||||
|
virtual void accept(ASTVisitor* visitor);
|
||||||
|
void addStatement(Statement* statement);
|
||||||
|
std::vector<Statement*> getStatements();
|
||||||
|
private:
|
||||||
|
std::vector<Statement*> statements_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATEMENTLIST_H
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "AST/ParameterList.h"
|
#include "AST/ParameterList.h"
|
||||||
#include "AST/ASTVisitor.h"
|
#include "AST/ASTVisitor.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
ParameterList::ParameterList() {
|
ParameterList::ParameterList() {
|
||||||
//
|
//
|
||||||
@@ -15,7 +14,6 @@ void ParameterList::accept(ASTVisitor* visitor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParameterList::addParameter(Type* type, std::string name) {
|
void ParameterList::addParameter(Type* type, std::string name) {
|
||||||
std::cout << "added parameter of type " << type->getName() << " and name " << name << std::endl;
|
|
||||||
params_.push_back(Parameter(type, name));
|
params_.push_back(Parameter(type, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
src/AST/StatementList.cpp
Normal file
22
src/AST/StatementList.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "AST/StatementList.h"
|
||||||
|
#include "AST/ASTVisitor.h"
|
||||||
|
|
||||||
|
StatementList::StatementList() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
StatementList::~StatementList() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatementList::accept(ASTVisitor* visitor) {
|
||||||
|
visitor->visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatementList::addStatement(Statement* statement) {
|
||||||
|
statements_.push_back(statement);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Statement*> StatementList::getStatements() {
|
||||||
|
return statements_;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user