Initial layout for binder
This commit is contained in:
parent
2df4a71ed8
commit
1e5cd010a1
|
@ -0,0 +1,6 @@
|
|||
|
||||
#include "Binder.hpp"
|
||||
|
||||
BoundScriptStatement *Binder::Bind(ParsedScriptStatement *s) {
|
||||
return nullptr;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
#ifndef PORYGONLANG_BINDER_HPP
|
||||
#define PORYGONLANG_BINDER_HPP
|
||||
|
||||
#include "../Parser/ParsedStatements/ParsedScriptStatement.hpp"
|
||||
#include "BoundStatements/BoundStatement.hpp"
|
||||
|
||||
class Binder {
|
||||
public:
|
||||
static BoundScriptStatement* Bind(ParsedScriptStatement* s);
|
||||
};
|
||||
|
||||
|
||||
#endif //PORYGONLANG_BINDER_HPP
|
|
@ -0,0 +1,49 @@
|
|||
#include <utility>
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_BOUNDSTATEMENT_HPP
|
||||
#define PORYGONLANG_BOUNDSTATEMENT_HPP
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
enum class BoundStatementKind{
|
||||
Script,
|
||||
Block,
|
||||
};
|
||||
|
||||
class BoundStatement{
|
||||
public:
|
||||
virtual BoundStatementKind GetKind() = 0;
|
||||
virtual ~BoundStatement() = default;
|
||||
};
|
||||
|
||||
class BoundBlockStatement : public BoundStatement{
|
||||
vector<BoundStatement*> _statements;
|
||||
public:
|
||||
explicit BoundBlockStatement(vector<BoundStatement*> statements){
|
||||
_statements = std::move(statements);
|
||||
}
|
||||
~BoundBlockStatement() override {
|
||||
for (auto s : _statements){
|
||||
delete s;
|
||||
}
|
||||
_statements.clear();
|
||||
}
|
||||
|
||||
BoundStatementKind GetKind() override{
|
||||
return BoundStatementKind ::Block;
|
||||
}
|
||||
};
|
||||
|
||||
class BoundScriptStatement : public BoundBlockStatement{
|
||||
public:
|
||||
explicit BoundScriptStatement(vector<BoundStatement*> statements) : BoundBlockStatement(std::move(statements)){
|
||||
}
|
||||
|
||||
BoundStatementKind GetKind() final{
|
||||
return BoundStatementKind ::Script;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //PORYGONLANG_BOUNDSTATEMENT_HPP
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
#ifndef PORYGONLANG_PARSEDSCRIPTSTATEMENT_HPP
|
||||
#define PORYGONLANG_PARSEDSCRIPTSTATEMENT_HPP
|
||||
|
||||
#include "ParsedStatement.hpp"
|
||||
|
||||
class ParsedScriptStatement : public ParsedBlockStatement{
|
||||
public:
|
||||
explicit ParsedScriptStatement(vector<ParsedStatement*> statements) : ParsedBlockStatement(move(statements)){}
|
||||
|
||||
ParsedStatementKind GetKind() final{
|
||||
return ParsedStatementKind ::Script;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //PORYGONLANG_PARSEDSCRIPTSTATEMENT_HPP
|
|
@ -1,5 +1,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_PARSEDSTATEMENT_HPP
|
||||
#define PORYGONLANG_PARSEDSTATEMENT_HPP
|
||||
|
@ -49,15 +51,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class ParsedScriptStatement : public ParsedBlockStatement{
|
||||
public:
|
||||
explicit ParsedScriptStatement(std::vector<ParsedStatement*> statements) : ParsedBlockStatement(statements){}
|
||||
|
||||
ParsedStatementKind GetKind() final{
|
||||
return ParsedStatementKind ::Script;
|
||||
}
|
||||
};
|
||||
|
||||
class ParsedExpressionStatement : public ParsedStatement{
|
||||
ParsedExpression* _expression;
|
||||
public:
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "Parser.hpp"
|
||||
#include "UnaryOperatorKind.hpp"
|
||||
#include "BinaryOperatorKind.hpp"
|
||||
#include "ParsedScriptStatement.hpp"
|
||||
|
||||
|
||||
ParsedScriptStatement* Parser::Parse() {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "ParsedStatements/ParsedStatement.hpp"
|
||||
#include "../Script.hpp"
|
||||
#include "ParsedScriptStatement.hpp"
|
||||
|
||||
enum class OperatorPrecedence {
|
||||
No,
|
||||
|
|
Loading…
Reference in New Issue