added an export for r8asm
This commit is contained in:
1 parent
baa7873a36
commit
16cabba2ee
2 files changed
+52
-15
No files matched your search
+39
-14
@@ -15,7 +15,40 @@ class r8asm {
|
||||
using general_data = int32_t;
|
||||
|
||||
private:
|
||||
public:
|
||||
enum class directive_t {
|
||||
MACRO,
|
||||
ENDMACRO,
|
||||
REP,
|
||||
ENDREP,
|
||||
INCLUDE,
|
||||
};
|
||||
std::map<std::string, directive_t> directive_map = {
|
||||
{"dir_macro", r8asm::directive_t::MACRO},
|
||||
{"dir_endmacro", r8asm::directive_t::ENDMACRO},
|
||||
{"dir_rep", r8asm::directive_t::REP},
|
||||
{"dir_endrep", r8asm::directive_t::ENDREP},
|
||||
{"dir_include", r8asm::directive_t::INCLUDE}};
|
||||
enum class token_t {
|
||||
STRING,
|
||||
OPERATOR,
|
||||
|
||||
PREFIX_DIRECTIVE,
|
||||
PREFIX_PARAMETER,
|
||||
PREFIX_BUILTIN,
|
||||
PREFIX_REMARK,
|
||||
|
||||
LPAREN,
|
||||
RPAREN,
|
||||
LQUOTE,
|
||||
RQUOTE,
|
||||
|
||||
ENDL,
|
||||
ENDF,
|
||||
};
|
||||
struct token {
|
||||
token_t type;
|
||||
std::string value;
|
||||
};
|
||||
enum class ast_node_t {
|
||||
CONSTANT,
|
||||
PARAMETER,
|
||||
@@ -94,18 +127,10 @@ public:
|
||||
|
||||
public:
|
||||
ast_node expand_node_to_ins(const ast_node &node);
|
||||
std::string expand_root();
|
||||
};
|
||||
enum class directive_t {
|
||||
MACRO,
|
||||
ENDMACRO,
|
||||
REP,
|
||||
ENDREP,
|
||||
INCLUDE,
|
||||
};
|
||||
std::map<std::string, directive_t> directive_map = {
|
||||
{"dir_macro", r8asm::directive_t::MACRO},
|
||||
{"dir_endmacro", r8asm::directive_t::ENDMACRO},
|
||||
{"dir_rep", r8asm::directive_t::REP},
|
||||
{"dir_endrep", r8asm::directive_t::ENDREP},
|
||||
{"dir_include", r8asm::directive_t::INCLUDE}};
|
||||
|
||||
ast main_tree;
|
||||
public:
|
||||
std::string export_rot8();
|
||||
};
|
||||
+13
-1
@@ -230,4 +230,16 @@ r8asm::ast_node r8asm::ast::expand_node_to_ins(const ast_node &node) {
|
||||
}
|
||||
return to_return;
|
||||
}
|
||||
#undef ROT8_NODE
|
||||
#undef ROT8_NODE
|
||||
|
||||
#define ROT8_BC_TO_CHAR(bc) ("><+-[].,"[static_cast<int>(bc)])
|
||||
std::string r8asm::ast::expand_root() {
|
||||
auto rot8_ins = expand_node_to_ins(root);
|
||||
std::string rot8_tape = "";
|
||||
for (const auto &i : rot8_ins.children)
|
||||
rot8_tape += ROT8_BC_TO_CHAR(rot8_map.at(i.value));
|
||||
return rot8_tape;
|
||||
}
|
||||
#undef ROT8_BC_TO_CHAR
|
||||
|
||||
std::string r8asm::export_rot8() { return main_tree.expand_root(); }
|
||||
Reference in new issue
Block a user