Removed statement invalid
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include "Parser/Statement/StatementMetaExternFunction.h"
|
||||
#include "Parser/Statement/StatementBlock.h"
|
||||
#include "Parser/Statement/StatementRepeat.h"
|
||||
#include "Parser/Statement/StatementInvalid.h"
|
||||
|
||||
Parser::Parser(vector<shared_ptr<Token>> tokens): tokens(tokens) {
|
||||
}
|
||||
@@ -246,7 +245,6 @@ shared_ptr<Statement> Parser::matchStatementFunction() {
|
||||
markError(TokenKind::SEMICOLON, {});
|
||||
return nullptr;
|
||||
}
|
||||
//return matchStatementInvalid("Expected a \";\" after a function declaration");
|
||||
|
||||
return make_shared<StatementFunction>(name, arguments, returnType, dynamic_pointer_cast<StatementBlock>(statementBlock));
|
||||
}
|
||||
@@ -311,8 +309,6 @@ shared_ptr<Statement> Parser::matchStatementRepeat() {
|
||||
|
||||
// initial
|
||||
initStatement = matchStatementVariable() ?: matchStatementAssignment();
|
||||
if (initStatement != nullptr && !initStatement->isValid())
|
||||
initStatement = nullptr;
|
||||
|
||||
if (!tryMatchingTokenKinds({TokenKind::COLON}, false, true)) {
|
||||
// got initial, expect comma
|
||||
@@ -369,8 +365,6 @@ shared_ptr<Statement> Parser::matchStatementExpression() {
|
||||
|
||||
if (expression == nullptr)
|
||||
return nullptr;
|
||||
else if (!expression->isValid())
|
||||
return make_shared<StatementInvalid>(tokens.at(currentIndex), "");// expression->toString(0));
|
||||
|
||||
return make_shared<StatementExpression>(expression);
|
||||
}
|
||||
@@ -601,8 +595,10 @@ shared_ptr<Expression> Parser::matchExpressionBlock(vector<TokenKind> terminalTo
|
||||
|
||||
while (!tryMatchingTokenKinds(terminalTokenKinds, false, false)) {
|
||||
shared_ptr<Statement> statement = nextInBlockStatement();
|
||||
if (statement == nullptr || !statement->isValid())
|
||||
return matchExpressionInvalid("Expected statement");
|
||||
if (statement == nullptr) {
|
||||
markError({}, "Expected statement");
|
||||
return nullptr;
|
||||
}
|
||||
statements.push_back(statement);
|
||||
|
||||
if (tryMatchingTokenKinds(terminalTokenKinds, false, false))
|
||||
|
||||
@@ -12,7 +12,6 @@ class Expression;
|
||||
class ExpressionInvalid;
|
||||
|
||||
class Statement;
|
||||
class StatementInvalid;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -6,7 +6,3 @@ kind(kind) { }
|
||||
StatementKind Statement::getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
bool Statement::isValid() {
|
||||
return kind != StatementKind::INVALID;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ enum class StatementKind {
|
||||
VARIABLE,
|
||||
ASSIGNMENT,
|
||||
REPEAT,
|
||||
META_EXTERN_FUNCTION,
|
||||
INVALID
|
||||
META_EXTERN_FUNCTION
|
||||
};
|
||||
|
||||
class Statement {
|
||||
@@ -27,7 +26,6 @@ public:
|
||||
Statement(StatementKind kind);
|
||||
virtual ~Statement() { }
|
||||
StatementKind getKind();
|
||||
bool isValid();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "Parser/Statement/StatementInvalid.h"
|
||||
|
||||
#include "Lexer/Token.h"
|
||||
|
||||
StatementInvalid::StatementInvalid(shared_ptr<Token> token, string message):
|
||||
Statement(StatementKind::INVALID), token(token), message(message) { }
|
||||
|
||||
string StatementInvalid::getMessage() {
|
||||
return message;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
#include "Parser/Statement/Statement.h"
|
||||
|
||||
class Token;
|
||||
|
||||
class StatementInvalid: public Statement {
|
||||
private:
|
||||
shared_ptr<Token> token;
|
||||
string message;
|
||||
|
||||
public:
|
||||
StatementInvalid(shared_ptr<Token> token, string message);
|
||||
string getMessage();
|
||||
};
|
||||
Reference in New Issue
Block a user