2019-05-21 10:59:15 +00:00
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
|
|
|
|
#include "Script.hpp"
|
2019-05-21 11:56:08 +00:00
|
|
|
#include "Parser/Lexer.hpp"
|
|
|
|
#include "Parser/Parser.hpp"
|
2019-05-21 18:59:26 +00:00
|
|
|
#include "Binder/Binder.hpp"
|
2019-05-21 10:59:15 +00:00
|
|
|
|
|
|
|
Script Script::Create(string script) {
|
|
|
|
auto s = Script();
|
|
|
|
s.Parse(std::move(script));
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2019-05-21 12:15:39 +00:00
|
|
|
Script::~Script() {
|
|
|
|
delete this -> Diagnostics;
|
2019-05-21 18:59:26 +00:00
|
|
|
delete this -> BoundScript;
|
2019-05-21 12:15:39 +00:00
|
|
|
}
|
|
|
|
|
2019-05-21 10:59:15 +00:00
|
|
|
void Script::Parse(string script) {
|
2019-05-21 11:56:08 +00:00
|
|
|
auto lexer = Lexer(std::move(script), this);
|
2019-05-21 10:59:15 +00:00
|
|
|
auto lexResult = lexer.Lex();
|
2019-05-21 12:00:14 +00:00
|
|
|
auto parser = Parser(lexResult, this);
|
2019-05-21 10:59:15 +00:00
|
|
|
auto parseResult = parser.Parse();
|
|
|
|
for (auto token : lexResult){
|
|
|
|
delete token;
|
|
|
|
}
|
|
|
|
lexResult.clear();
|
2019-05-21 18:59:26 +00:00
|
|
|
if (!Diagnostics->HasErrors()){
|
2019-05-22 10:37:49 +00:00
|
|
|
this->BoundScript = Binder::Bind(this, parseResult);
|
2019-05-21 18:59:26 +00:00
|
|
|
}
|
|
|
|
delete parseResult;
|
2019-05-21 10:59:15 +00:00
|
|
|
}
|
2019-05-21 12:15:39 +00:00
|
|
|
|