2017-06-04 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
namespace EightBit {
|
|
|
|
class Symbols {
|
|
|
|
public:
|
2018-08-11 20:19:19 +00:00
|
|
|
Symbols(std::string path = "") noexcept;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
const std::map<uint16_t, std::string>& getLabels() const { return labels; }
|
|
|
|
const std::map<uint16_t, std::string>& getConstants() const { return constants; }
|
|
|
|
const std::map<std::string, uint16_t>& getScopes() const { return scopes; }
|
|
|
|
const std::map<std::string, uint64_t>& getAddresses() const { return addresses; }
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
private:
|
|
|
|
void AssignScopes();
|
|
|
|
void AssignSymbols();
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
void Parse(std::string path);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
std::map<uint16_t, std::string> labels;
|
|
|
|
std::map<uint16_t, std::string> constants;
|
|
|
|
std::map<std::string, uint16_t> scopes;
|
|
|
|
std::map<std::string, uint64_t> addresses;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
struct kv_pair_t {
|
|
|
|
std::map<std::string, std::string> element;
|
|
|
|
};
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
std::vector<std::string> split(const std::string& input, const std::vector<std::string>& delimiters);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
std::map<std::string, std::map<std::string, kv_pair_t>> parsed;
|
|
|
|
};
|
|
|
|
}
|