Compare commits
2 Commits
51de990690
...
3e3330b046
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e3330b046 | |||
| 7eee6a08c8 |
10
main.cpp
10
main.cpp
@@ -3,6 +3,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
// Comp map
|
// Comp map
|
||||||
const std::map<std::string, std::string> compMap = {
|
const std::map<std::string, std::string> compMap = {
|
||||||
@@ -92,7 +95,14 @@ static inline std::string strip(const std::string &s) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using symbolsMap = std::map<std::string, int>;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
// Load predefined symbols
|
||||||
|
std::ifstream file("./symbols.json");
|
||||||
|
nlohmann::json symbols_json = nlohmann::json::parse(file);
|
||||||
|
symbolsMap symbols_map = symbols_json.get<symbolsMap>();
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(std::cin, line)) {
|
while (std::getline(std::cin, line)) {
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
|
|||||||
27
symbols.json
Normal file
27
symbols.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"SP": 0,
|
||||||
|
"LCL": 1,
|
||||||
|
"ARG": 2,
|
||||||
|
"THIS": 3,
|
||||||
|
"THAT": 4,
|
||||||
|
|
||||||
|
"R0": 0,
|
||||||
|
"R1": 1,
|
||||||
|
"R2": 2,
|
||||||
|
"R3": 3,
|
||||||
|
"R4": 4,
|
||||||
|
"R5": 5,
|
||||||
|
"R6": 6,
|
||||||
|
"R7": 7,
|
||||||
|
"R8": 8,
|
||||||
|
"R9": 9,
|
||||||
|
"R10": 10,
|
||||||
|
"R11": 11,
|
||||||
|
"R12": 12,
|
||||||
|
"R13": 13,
|
||||||
|
"R14": 14,
|
||||||
|
"R15": 15,
|
||||||
|
|
||||||
|
"SCREEN": 16384,
|
||||||
|
"KBD": 24576
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user