Extract preprocessing from tokenizer

This commit is contained in:
2020-08-29 11:25:10 +02:00
parent aebc1dd86d
commit 71678b2ec6
12 changed files with 254 additions and 134 deletions

View File

@@ -1,5 +1,6 @@
#include <fstream>
#include <interpret/errors.hpp>
#include <preprocessor/preprocessor.hpp>
#include <token/errors.hpp>
#include <wassembler.hpp>
@@ -48,7 +49,6 @@ bool Wassembler::LoadLinesFromFile(std::string const & filePath, std::vector<std
return true;
}
bool Wassembler::LoadTokens(std::vector<std::string> const & lines, std::vector<Token::Token> & tokens) const
{
Token::Tokenizer tokenizer;
@@ -86,6 +86,11 @@ void Wassembler::SetMemorySize(unsigned const size)
config.memorySize = size;
}
void Wassembler::EnableSubstitutionsLogging()
{
printSubstitutions = true;
}
bool Wassembler::LoadFromFile(std::string const & filePath)
{
std::vector<std::string> lines;
@@ -95,6 +100,13 @@ bool Wassembler::LoadFromFile(std::string const & filePath)
return false;
}
Preprocessor preprocessor;
preprocessor.process(lines);
if (printSubstitutions)
{
preprocessor.printSubstitutions();
}
std::vector<Token::Token> tokens;
if (!LoadTokens(lines, tokens))
{