Extract preprocessing from tokenizer
This commit is contained in:
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user