31 std::println(
"Success! Output to {}",
m_args.outputFile.string());
36 std::println(
"Failed to assemble program!");
43 m_args.program = std::filesystem::path(argv[0]);
44 for (
int i = 1; i < argc; i++)
46 std::string arg = argv[i];
48 if (arg ==
"-h" || arg ==
"--help")
53 else if (arg ==
"-o" || arg ==
"--output")
57 m_args.outputFile = argv[++i];
61 std::println(std::cerr,
"Error: {} requires an argument", arg);
66 if (arg ==
"-s" || arg ==
"--silent")
70 else if (arg[0] ==
'-')
72 std::println(std::cerr,
"Error: Unknown option: {}", arg);
78 if (
m_args.inputFile.empty())
82 std::println(std::cerr,
"Error: Multiple input files specified");
93 std::println(
"Phasor Assembler v{}\n"
94 "(C) 2026 Daniel McGuire - Licensed under Apache 2.0\n\n"
96 " {} [options] <input.phsb>\n\n"
98 " -o, --output <file> Output file\n"
99 " -h, --help Show this help message\n"
100 " -s, --silent Do not print anything except errors (no stdout)",
101 PHASOR_VERSION_STRING,
m_args.program.stem().string());
109 if (
m_args.outputFile.empty())
112 std::filesystem::path path(
m_args.outputFile);
113 path.replace_extension(
".phsb");
114 m_args.outputFile = path.string();
struct Phasor::Assembler::Args m_args
Assembler(int argc, char *argv[])
bool parseArguments(int argc, char *argv[])
Bytecode binary format serializer.
bool saveToFile(const Bytecode &bytecode, const std::filesystem::path &filename)
Save bytecode to .phsb file.
Phasor IR Serializer/Deserializer.
static Bytecode loadFromFile(const std::filesystem::path &filename)
Load bytecode from .phir file.
The Phasor Programming Language and Runtime.