parent
a1391708b2
commit
8614e08569
4 changed files with 40 additions and 2 deletions
@ -1,10 +1,18 @@ |
|||||||
|
#include <iostream> |
||||||
|
|
||||||
#include "Compiler.hpp" |
#include "Compiler.hpp" |
||||||
|
|
||||||
|
|
||||||
namespace dumb { |
namespace dumb { |
||||||
|
|
||||||
Compiler::Compiler(ArgumentList file) : sourceFile(std::filesystem::current_path() / std::filesystem::path(file.at(0))), |
Compiler::Compiler(ArgumentList file) : sourceFile(std::filesystem::current_path() / std::filesystem::path(file.at(0))), |
||||||
lexer(std::make_unique<Lexer>(this->sourceFile)) { |
lexer(std::make_unique<Lexer>(*this, this->sourceFile)) { |
||||||
this->lexer->tokenize(); |
|
||||||
|
const Lexer::TokenStream& tokenStream = this->lexer->tokenize(); |
||||||
|
this->parser = std::make_unique<Parser>(*this, tokenStream); |
||||||
|
} |
||||||
|
|
||||||
|
void Compiler::reportError(std::string message, Token &token) { |
||||||
|
std::cout << message << '\n'; |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,8 @@ |
|||||||
|
#include "Parser.hpp" |
||||||
|
|
||||||
|
namespace dumb { |
||||||
|
|
||||||
|
Parser::Parser(Compiler &compiler, const Lexer::TokenStream& tokenStream) : compiler(compiler), tokenStream(tokenStream), pointer(0) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include "Lexer.hpp" |
||||||
|
|
||||||
|
namespace dumb { |
||||||
|
class Compiler; |
||||||
|
|
||||||
|
class Parser { |
||||||
|
private: |
||||||
|
Compiler& compiler; |
||||||
|
const Lexer::TokenStream& tokenStream; |
||||||
|
size_t pointer; |
||||||
|
public: |
||||||
|
Parser(Compiler& compiler, const Lexer::TokenStream& tokenStream); |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue