Files
r8asm_rev-fork/tests/r8_test.cc
starcells 3f3e431d64 r8asm: say what is wrong instead of dying or lying
A typo used to end in one of three ways: std::out_of_range aborting the
process (unknown macro, unknown directive), a silent 0 (unknown name used
as an address, which quietly mis-assembles), or a silent empty tape (a
file or %include that could not be opened).  All four now go through
ast::fail(), print a line on stderr, set the error flag and make the CLI
exit with 1.  Names that are reported repeatedly are only printed once.

While here: import_file set the cell size *after* parsing, so the
%include handler read main_tree.CELL_SIZE before it had ever been set and
handed 0 to included files.  It worked by accident because the top-level
call ran again at the end.  Moved it before the parse.

r8asm_test.cc came from the working tree (argv instead of a hard-coded
path); it now also checks the arguments and the error flag.
2026-11-05 22:49:54 +08:00

19 lines
354 B
C++

#include "r8asm/r8asm.hh"
#include <iostream>
int main(int argc, char **argv) {
if (argc < 2) {
std::cerr << "usage: r8asm_test <file.r8asm>" << std::endl;
return (2);
}
r8asm a;
if (!a.import_file(argv[1], 8))
return (1);
std::string tape = a.export_rot8();
if (a.failed())
return (1);
std::cout << tape;
return (0);
}