From 4fa4f128d54de9c68ae58ea6308521fbe2048f95 Mon Sep 17 00:00:00 2001 From: avinal <185067@nith.ac.in> Date: Mon, 10 Aug 2020 16:10:12 +0530 Subject: [PATCH] Minor changes --- include/parser.hpp | 6 +++--- include/symbol_table.hpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/parser.hpp b/include/parser.hpp index 06a5f16..c2d1743 100644 --- a/include/parser.hpp +++ b/include/parser.hpp @@ -1,15 +1,15 @@ #include #include #include -#include #include #include +#include "symbol_table.hpp" class parser { private: std::string filename; - int count_ins = 0; + symbol_table table; public: parser() {} @@ -18,7 +18,7 @@ public: void assemble(); std::vector> get_machine_code; char command_type(std::string mnemonic); - std::string symbol(); + void create_table(); std::string dest(std::string des); std::string comp(std::string com); std::string jump(std::string jum); diff --git a/include/symbol_table.hpp b/include/symbol_table.hpp index 5f1c449..53afdec 100644 --- a/include/symbol_table.hpp +++ b/include/symbol_table.hpp @@ -32,10 +32,11 @@ private: {"SCREEN", 16384}, {"KBD", 24576}, }; + int next = 15; public: symbol_table() {} - + int available(); void add_entry(std::string symbol, int address); bool contains(std::string symbol); int get_address(std::string symbol);