202608290010
This commit is contained in:
1 parent
a96e7ffa87
commit
5aa4893dc6
3 files changed
+140
-24
No files matched your search
+10
-9
@@ -9,6 +9,8 @@
|
||||
|
||||
constexpr size_t CELL_SIZE = 8;
|
||||
|
||||
namespace r8asm_maps {}
|
||||
|
||||
class r8asm {
|
||||
using data = int16_t;
|
||||
using parameter_index = uint8_t;
|
||||
@@ -29,7 +31,6 @@ private:
|
||||
DIRECTIVE,
|
||||
PARAMETER,
|
||||
BUILTIN,
|
||||
PREFIX_REMARK,
|
||||
|
||||
LPAREN,
|
||||
RPAREN,
|
||||
@@ -50,8 +51,11 @@ private:
|
||||
std::string filename;
|
||||
std::vector<token_line> lines;
|
||||
|
||||
const std::set<std::string> raw_rot8_ins = {"stp", "btp", "ror", "flb",
|
||||
"biz", "rnz", "out", "inp"};
|
||||
|
||||
token_stream(const std::string &filename);
|
||||
std::vector<token_line> lex(const std::string &in_chars);
|
||||
std::vector<token_line> lex(const std::string &char_stream);
|
||||
};
|
||||
|
||||
enum class ast_node_t {
|
||||
@@ -124,7 +128,6 @@ private:
|
||||
AND,
|
||||
OR,
|
||||
NOT,
|
||||
NEG,
|
||||
};
|
||||
|
||||
const std::map<std::string, operator_t> operator_map = {
|
||||
@@ -132,11 +135,11 @@ private:
|
||||
{"op_mul", operator_t::MUL}, {"op_div", operator_t::DIV},
|
||||
{"op_xor", operator_t::XOR}, {"op_and", operator_t::AND},
|
||||
{"op_or", operator_t::OR}, {"op_not", operator_t::NOT},
|
||||
{"op_neg", operator_t::NEG}};
|
||||
};
|
||||
const std::map<operator_t, precedence_t> op_precedence_map = {
|
||||
{operator_t::NEG, 0}, {operator_t::NOT, 0}, {operator_t::MUL, 1},
|
||||
{operator_t::DIV, 1}, {operator_t::ADD, 2}, {operator_t::SUB, 2},
|
||||
{operator_t::AND, 3}, {operator_t::XOR, 4}, {operator_t::OR, 5},
|
||||
{operator_t::NOT, 0}, {operator_t::MUL, 1}, {operator_t::DIV, 1},
|
||||
{operator_t::ADD, 2}, {operator_t::SUB, 2}, {operator_t::AND, 3},
|
||||
{operator_t::XOR, 4}, {operator_t::OR, 5},
|
||||
};
|
||||
ast_node expand_node_to_ins(const ast_node &node);
|
||||
std::string expand_root();
|
||||
@@ -162,8 +165,6 @@ private:
|
||||
ast_node parse(const token_stream &stream);
|
||||
ast_node parse_args(const token_line &line);
|
||||
ast_node parse_single_arg(const token_line &line);
|
||||
token_stream lex(const std::string &char_stream);
|
||||
bool is_integer(const std::string &str);
|
||||
|
||||
public:
|
||||
std::string export_rot8();
|
||||
|
||||
Reference in new issue
Block a user