Load symbols from the json
This commit is contained in:
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user