// The assembler CLI. // // r8forge [--synth-chars] // // %synth charges a block for a layout free tape by default: the block is // copied to many call sites, so the .tp walk is not part of the search and one // cache entry serves every layout. --synth-chars charges the real characters // for the layout written in the source instead (much slower, and the result is // only optimal for that layout). It is a property of the run, not of a block, // which is why there is no `metric` line inside %synth any more. #include "r8forge/r8asm.hh" #include #include namespace { void usage() { std::cerr << "usage: r8forge [--synth-chars] \n"; } } // namespace int main(int argc, char **argv) { const char *file = nullptr; int metric = 1; // layout free for (int i = 1; i < argc; i++) { const std::string arg = argv[i]; if (arg == "--synth-chars") { metric = 0; } else if (arg == "--synth-flat") { metric = 1; } else if (arg == "-h" || arg == "--help") { usage(); return (0); } else if (arg.size() > 1 && arg[0] == '-') { std::cerr << "unknown option '" << arg << "'\n"; usage(); return (2); } else if (file == nullptr) { file = argv[i]; } else { usage(); return (2); } } if (file == nullptr) { usage(); return (2); } r8asm a; a.set_synth_metric(metric); if (!a.import_file(file, kDefaultCellSize)) return (1); std::string tape = a.export_rot8(); if (a.failed()) return (1); std::cout << tape; return (0); }