2020-08-08 11:55:34 +05:30
|
|
|
#include <fstream>
|
2020-08-10 12:21:58 +05:30
|
|
|
#include <vector>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <bitset>
|
2020-08-08 11:55:34 +05:30
|
|
|
|
2020-08-10 12:21:58 +05:30
|
|
|
class parser
|
2020-08-08 11:55:34 +05:30
|
|
|
{
|
|
|
|
|
private:
|
2020-08-10 12:21:58 +05:30
|
|
|
std::string filename;
|
|
|
|
|
int count_ins = 0;
|
2020-08-08 11:55:34 +05:30
|
|
|
|
|
|
|
|
public:
|
2020-08-10 12:21:58 +05:30
|
|
|
parser() {}
|
|
|
|
|
parser(std::string input_file) : filename(input_file) {}
|
2020-08-08 11:55:34 +05:30
|
|
|
|
2020-08-10 12:21:58 +05:30
|
|
|
void assemble();
|
|
|
|
|
std::vector<std::array<char, 16>> get_machine_code;
|
|
|
|
|
char command_type(std::string mnemonic);
|
2020-08-08 11:55:34 +05:30
|
|
|
std::string symbol();
|
2020-08-10 12:21:58 +05:30
|
|
|
std::string dest(std::string des);
|
|
|
|
|
std::string comp(std::string com);
|
|
|
|
|
std::string jump(std::string jum);
|
|
|
|
|
std::array<std::string, 3> split(std::string mnemonic);
|
2020-08-08 11:55:34 +05:30
|
|
|
};
|