/* *****************************************************************************
* %{QMAKE_PROJECT_NAME}
* Copyright (c) %YEAR% killerbee
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
* ****************************************************************************/
#ifndef ACTION_ENUM_H
#define ACTION_ENUM_H
#include "microcode-long.hpp"
namespace mc_long {
[[nodiscard]] constexpr auto parse_microcode_iospec_(std::string_view in,
std::size_t& read,
bool& term)
-> actions::act {
auto working = [&] {
for (auto [c, i] : kblib::enumerate(in)) {
if (c == ';' or c == ',') {
read = i + 1;
term = (c == ';');
return in.substr(0, i);
}
}
throw "no terminator";
}();
constexpr std::pair table[]{
{"-", actions::act::nil},
{"r1r0", actions::act::r1r0}, {"r1r1", actions::act::r1r1},
{"r1r2", actions::act::r1r2}, {"r1r3", actions::act::r1r3},
{"r1r4", actions::act::r1r4}, {"r1r5", actions::act::r1r5},
{"r1r6", actions::act::r1r6}, {"r1r7", actions::act::r1r7},
{"r1r8", actions::act::r1r8}, {"r1r9", actions::act::r1r9},
{"r1r10", actions::act::r1r10}, {"r1r11", actions::act::r1r11},
{"r1r12", actions::act::r1r12}, {"r1r13", actions::act::r1r13},
{"r1r14", actions::act::r1r14}, {"r1r15", actions::act::r1r15},
{"r1PS", actions::act::r1PS}, {"r1HS", actions::act::r1HS},
{"r1CS", actions::act::r1CS}, {"r1NS", actions::act::r1NS},
{"r1L", actions::act::r1L}, {"r1R", actions::act::r1R},
{"r1sA", actions::act::r1sA}, {"r1A", actions::act::r1A},
{"r1B", actions::act::r1B}, {"r1C", actions::act::r1C},
{"r1D", actions::act::r1D}, {"r1no", actions::act::r1no},
{"r1i", actions::act::r1i},
{"r2r0", actions::act::r2r0}, {"r2r1", actions::act::r2r1},
{"r2r2", actions::act::r2r2}, {"r2r3", actions::act::r2r3},
{"r2r4", actions::act::r2r4}, {"r2r5", actions::act::r2r5},
{"r2r6", actions::act::r2r6}, {"r2r7", actions::act::r2r7},
{"r2r8", actions::act::r2r8}, {"r2r9", actions::act::r2r9},
{"r2r10", actions::act::r2r10}, {"r2r11", actions::act::r2r11},
{"r2r12", actions::act::r2r12}, {"r2r13", actions::act::r2r13},
{"r2r14", actions::act::r2r14}, {"r2r15", actions::act::r2r15},
{"r2PS", actions::act::r2PS}, {"r2HS", actions::act::r2HS},
{"r2CS", actions::act::r2CS}, {"r2NS", actions::act::r2NS},
{"r2L", actions::act::r2L}, {"r2R", actions::act::r2R},
{"r2sA", actions::act::r2sA}, {"r2A", actions::act::r2A},
{"r2B", actions::act::r2B}, {"r2C", actions::act::r2C},
{"r2D", actions::act::r2D}, {"r2no", actions::act::r2no},
{"r2i", actions::act::r2i},
{"R", actions::act::R}, {"RsA", actions::act::RsA},
{"RsB", actions::act::RsB}, {"RsC", actions::act::RsC},
{"RsD", actions::act::RsD}, {"RdA", actions::act::RdA},
{"RdB", actions::act::RdB}, {"RdC", actions::act::RdC},
{"RdD", actions::act::RdD}, {"RAA", actions::act::RAA},
{"RAB", actions::act::RAB}, {"RAC", actions::act::RAC},
{"RAD", actions::act::RAD}, {"RBA", actions::act::RBA},
{"RBB", actions::act::RBB}, {"RBC", actions::act::RBC},
{"RBD", actions::act::RBD}, {"RCA", actions::act::RCA},
{"RCB", actions::act::RCB}, {"RCC", actions::act::RCC},
{"RCD", actions::act::RCD}, {"RDA", actions::act::RDA},
{"RDB", actions::act::RDB}, {"RDC", actions::act::RDC},
{"RDD", actions::act::RDD},
{"Cno", actions::act::Cno},
{"w1A", actions::act::w1A}, {"w1B", actions::act::w1B},
{"w1C", actions::act::w1C}, {"w1D", actions::act::w1D},
{"w1r0", actions::act::w1r0}, {"w1r1", actions::act::w1r1},
{"w1w1", actions::act::w1r2}, {"w1r3", actions::act::w1r3},
{"w1r4", actions::act::w1r4}, {"w1r5", actions::act::w1r5},
{"w1r6", actions::act::w1r6}, {"w1r7", actions::act::w1r7},
{"w1r8", actions::act::w1r8}, {"w1r9", actions::act::w1r9},
{"w1r10", actions::act::w1r10}, {"w1r11", actions::act::w1r11},
{"w1r12", actions::act::w1r12}, {"w1r13", actions::act::w1r13},
{"w1r14", actions::act::w1r14}, {"w1r15", actions::act::w1r15},
{"w1PS", actions::act::w1PS}, {"w1HS", actions::act::w1HS},
{"w1CS", actions::act::w1CS}, {"w1NS", actions::act::w1NS},
{"w1L", actions::act::w1L}, {"w1R", actions::act::w1R},
{"w1sA", actions::act::w1sA},
{"w2A", actions::act::w2A}, {"w2B", actions::act::w2B},
{"w2C", actions::act::w2C}, {"w2D", actions::act::w2D},
{"w2r0", actions::act::w2r0}, {"w2r1", actions::act::w2r1},
{"w2w2", actions::act::w2w2}, {"w2r3", actions::act::w2r3},
{"w2r4", actions::act::w2r4}, {"w2r5", actions::act::w2r5},
{"w2r6", actions::act::w2r6}, {"w2r7", actions::act::w2r7},
{"w2r8", actions::act::w2r8}, {"w2r9", actions::act::w2r9},
{"w2r10", actions::act::w2r10}, {"w2r11", actions::act::w2r11},
{"w2r12", actions::act::w2r12}, {"w2r13", actions::act::w2r13},
{"w2r14", actions::act::w2r14}, {"w2r15", actions::act::w2r15},
{"w2PS", actions::act::w2PS}, {"w2HS", actions::act::w2HS},
{"w2CS", actions::act::w2CS}, {"w2NS", actions::act::w2NS},
{"w2L", actions::act::w2L}, {"w2R", actions::act::w2R},
{"w2sA", actions::act::w2sA},
{"W", actions::act::W}, {"WsA", actions::act::WsA},
{"WsB", actions::act::WsB}, {"WsC", actions::act::WsC},
{"WsD", actions::act::WsD}, {"WdA", actions::act::WdA},
{"WdB", actions::act::WdB}, {"WdC", actions::act::WdC},
{"WdD", actions::act::WdD}, {"WAA", actions::act::WAA},
{"WAB", actions::act::WAB}, {"WAC", actions::act::WAC},
{"WAD", actions::act::WAD}, {"WBA", actions::act::WBA},
{"WBB", actions::act::WBB}, {"WBC", actions::act::WBC},
{"WBD", actions::act::WBD}, {"WCA", actions::act::WCA},
{"WCB", actions::act::WCB}, {"WCC", actions::act::WCC},
{"WCD", actions::act::WCD}, {"WDA", actions::act::WDA},
{"WDB", actions::act::WDB}, {"WDC", actions::act::WDC},
{"WDD", actions::act::WDD},
};
for (auto e : table) {
if (working == e.first) {
return e.second;
}
}
throw "invalid iospec";
}
} // namespace mc_long
#endif // ACTION_ENUM_H