Removed virtual toString from Statement
This commit is contained in:
@@ -29,7 +29,7 @@ vector<shared_ptr<Statement>> Parser::getStatements() {
|
||||
shared_ptr<Statement> statement = nextStatement();
|
||||
// Abort parsing if we got an error
|
||||
if (!statement->isValid()) {
|
||||
cerr << statement->toString(0);
|
||||
//cerr << statement->toString(0);
|
||||
exit(1);
|
||||
}
|
||||
statements.push_back(statement);
|
||||
|
||||
@@ -10,7 +10,3 @@ StatementKind Statement::getKind() {
|
||||
bool Statement::isValid() {
|
||||
return kind != StatementKind::INVALID;
|
||||
}
|
||||
|
||||
string Statement::toString(int indent) {
|
||||
return "STATEMENT";
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ private:
|
||||
|
||||
public:
|
||||
Statement(StatementKind kind);
|
||||
virtual ~Statement() {}
|
||||
StatementKind getKind();
|
||||
bool isValid();
|
||||
virtual string toString(int indent);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -8,16 +8,3 @@ Statement(StatementKind::BLOCK), statements(statements) { }
|
||||
vector<shared_ptr<Statement>> StatementBlock::getStatements() {
|
||||
return statements;
|
||||
}
|
||||
|
||||
string StatementBlock::toString(int indent) {
|
||||
string value;
|
||||
for (int i=0; i<statements.size(); i++) {
|
||||
//for (int ind=0; ind<indent; ind++)
|
||||
// value += " ";
|
||||
value += statements.at(i)->toString(indent);
|
||||
}
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += "#\n";
|
||||
return value;
|
||||
}
|
||||
@@ -9,5 +9,4 @@ private:
|
||||
public:
|
||||
StatementBlock(vector<shared_ptr<Statement>> statements);
|
||||
vector<shared_ptr<Statement>> getStatements();
|
||||
string toString(int indent) override;
|
||||
};
|
||||
@@ -8,12 +8,3 @@ Statement(StatementKind::EXPRESSION), expression(expression) { }
|
||||
shared_ptr<Expression> StatementExpression::getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
string StatementExpression::toString(int indent) {
|
||||
string value;
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += expression->toString(indent);
|
||||
value += "\n";
|
||||
return value;
|
||||
}
|
||||
@@ -9,5 +9,4 @@ private:
|
||||
public:
|
||||
StatementExpression(shared_ptr<Expression> expression);
|
||||
shared_ptr<Expression> getExpression();
|
||||
string toString(int indent) override;
|
||||
};
|
||||
@@ -43,17 +43,3 @@ ValueType StatementFunction::getReturnValueType() {
|
||||
shared_ptr<StatementBlock> StatementFunction::getStatementBlock() {
|
||||
return statementBlock;
|
||||
}
|
||||
|
||||
string StatementFunction::toString(int indent) {
|
||||
string value = "";
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += "FUNCTION(";
|
||||
value += valueTypeToString(returnValueType);
|
||||
value += ", " + name + "):\n";
|
||||
value += statementBlock->toString(indent+1);
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += ";";
|
||||
return value;
|
||||
}
|
||||
@@ -15,5 +15,4 @@ public:
|
||||
vector<pair<string, ValueType>> getArguments();
|
||||
ValueType getReturnValueType();
|
||||
shared_ptr<StatementBlock> getStatementBlock();
|
||||
string toString(int indent) override;
|
||||
};
|
||||
@@ -5,10 +5,6 @@
|
||||
StatementInvalid::StatementInvalid(shared_ptr<Token> token, string message):
|
||||
Statement(StatementKind::INVALID), token(token), message(message) { }
|
||||
|
||||
string StatementInvalid::toString(int indent) {
|
||||
return "Error for token " + token->toString() + " at " + to_string(token->getLine()) + ":" + to_string(token->getColumn()) + ": " + message + "\n";
|
||||
}
|
||||
|
||||
string StatementInvalid::getMessage() {
|
||||
return message;
|
||||
}
|
||||
@@ -9,6 +9,5 @@ private:
|
||||
|
||||
public:
|
||||
StatementInvalid(shared_ptr<Token> token, string message);
|
||||
string toString(int indent) override;
|
||||
string getMessage();
|
||||
};
|
||||
|
||||
@@ -27,14 +27,3 @@ vector<pair<string, ValueType>> StatementMetaExternFunction::getArguments() {
|
||||
ValueType StatementMetaExternFunction::getReturnValueType() {
|
||||
return returnValueType;
|
||||
}
|
||||
|
||||
string StatementMetaExternFunction::toString(int indent) {
|
||||
string value;
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += "EXTERN_FUN(";
|
||||
value += name + ", ";
|
||||
value += valueTypeToString(returnValueType);
|
||||
value += ")\n";
|
||||
return value;
|
||||
}
|
||||
@@ -11,5 +11,4 @@ public:
|
||||
string getName();
|
||||
vector<pair<string, ValueType>> getArguments();
|
||||
ValueType getReturnValueType();
|
||||
string toString(int indent) override;
|
||||
};
|
||||
@@ -21,19 +21,3 @@ shared_ptr<Expression> StatementRepeat::getPostConditionExpression() {
|
||||
shared_ptr<StatementBlock> StatementRepeat::getBodyBlockStatement() {
|
||||
return bodyBlockStatement;
|
||||
}
|
||||
|
||||
string StatementRepeat::toString(int indent) {
|
||||
string value;
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += "REP(";
|
||||
if (initStatement != nullptr)
|
||||
value += initStatement->toString(0), ", ";
|
||||
if (preConditionExpression != nullptr)
|
||||
value += preConditionExpression->toString(0) + ", ";
|
||||
if (postConditionExpression != nullptr)
|
||||
value += postConditionExpression->toString(0);
|
||||
value += "):\n";
|
||||
value += bodyBlockStatement->toString(indent+1);
|
||||
return value;
|
||||
}
|
||||
@@ -16,5 +16,4 @@ public:
|
||||
shared_ptr<Expression> getPreConditionExpression();
|
||||
shared_ptr<Expression> getPostConditionExpression();
|
||||
shared_ptr<StatementBlock> getBodyBlockStatement();
|
||||
string toString(int indent) override;
|
||||
};
|
||||
@@ -8,18 +8,3 @@ Statement(StatementKind::RETURN), expression(expression) { }
|
||||
shared_ptr<Expression> StatementReturn::getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
string StatementReturn::toString(int indent) {
|
||||
string value;
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += "RETURN";
|
||||
if (expression != nullptr) {
|
||||
value += ":\n";
|
||||
for (int ind=0; ind<indent+1; ind++)
|
||||
value += " ";
|
||||
value += expression->toString(indent+1);
|
||||
}
|
||||
value += "\n";
|
||||
return value;
|
||||
}
|
||||
@@ -9,5 +9,4 @@ private:
|
||||
public:
|
||||
StatementReturn(shared_ptr<Expression> expression);
|
||||
shared_ptr<Expression> getExpression();
|
||||
string toString(int indent) override;
|
||||
};
|
||||
@@ -29,17 +29,3 @@ ValueType StatementVariable::getValueType() {
|
||||
shared_ptr<Expression> StatementVariable::getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
string StatementVariable::toString(int indent) {
|
||||
string value;
|
||||
for (int ind=0; ind<indent; ind++)
|
||||
value += " ";
|
||||
value += name + "(";
|
||||
value += valueTypeToString(valueType);
|
||||
value += "):\n";
|
||||
for (int ind=0; ind<indent+1; ind++)
|
||||
value += " ";
|
||||
value += expression->toString(indent+1);
|
||||
value += "\n";
|
||||
return value;
|
||||
}
|
||||
@@ -13,5 +13,4 @@ public:
|
||||
string getName();
|
||||
ValueType getValueType();
|
||||
shared_ptr<Expression> getExpression();
|
||||
string toString(int indent) override;
|
||||
};
|
||||
Reference in New Issue
Block a user