41 lines
714 B
C++
41 lines
714 B
C++
#ifndef DLANG_COMPILER_HPP
|
|
#define DLANG_COMPILER_HPP
|
|
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "types/include.hpp"
|
|
#include "program.hpp"
|
|
|
|
#include "parser/expressions.hpp"
|
|
#include "parser/statements.hpp"
|
|
|
|
class Compiler
|
|
{
|
|
private:
|
|
std::vector<double> _bytecode;
|
|
std::vector<std::string> _stringTable;
|
|
std::vector<std::string> _includes;
|
|
Program* _program = nullptr;
|
|
|
|
private:
|
|
void Emit(Opcodes op);
|
|
void Emit(const std::string& str);
|
|
void Emit(double value);
|
|
|
|
void Compile(Statement* stmt);
|
|
void Compile(Expression* expr);
|
|
|
|
void FinalCompile();
|
|
|
|
public:
|
|
Compiler(Program* program);
|
|
|
|
void Compile();
|
|
const std::vector<double>& GetBytecode() const;
|
|
|
|
void Print();
|
|
};
|
|
|
|
#endif |