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
|
|
|
|
2018-11-04 13:27:43 +00:00
|
|
|
const std::map<uint16_t, std::string>& labels() const { return m_labels; }
|
|
|
|
const std::map<uint16_t, std::string>& constants() const { return m_constants; }
|
|
|
|
const std::map<std::string, uint16_t>& scopes() const { return m_scopes; }
|
|
|
|
const std::map<std::string, uint64_t>& addresses() const { return m_addresses; }
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-07-02 21:03:33 +00:00
|
|
|
private:
|
2018-11-04 13:27:43 +00:00
|
|
|
static std::vector<std::string> split(const std::string& input, const std::string& regex);
|
|
|
|
|
|
|
|
void assignScopes();
|
|
|
|
void assignSymbols();
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2018-11-04 13:27:43 +00:00
|
|
|
void parse(std::string path);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2018-11-04 13:27:43 +00:00
|
|
|
std::map<uint16_t, std::string> m_labels;
|
|
|
|
std::map<uint16_t, std::string> m_constants;
|
|
|
|
std::map<std::string, uint16_t> m_scopes;
|
|
|
|
std::map<std::string, uint64_t> m_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;
|
|
|
|
};
|
2018-11-04 13:27:43 +00:00
|
|
|
std::map<std::string, std::map<std::string, kv_pair_t>> m_parsed;
|
2017-07-02 21:03:33 +00:00
|
|
|
};
|
2018-11-04 13:27:43 +00:00
|
|
|
}
|