From 0329cc56051b60dac2fec0464adf0d2b7e3a5305 Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Thu, 26 Jan 2023 22:59:27 +0100 Subject: [PATCH] Made help into a proper readme too --- README.md | 34 ++++++++++++++++++++++++++++++++++ src/main.cpp | 37 +++++++++++++++++++++++-------------- 2 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2895200 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# Sugar + +## Commands + +lex : string ➔ lexed_output +> takes a filename to a file that must be compiled + +merge : lexed_output lexed_output ➔ lexed_output +> merges two lexed modules together + +parse : lexed_output ➔ parsed_output +> prepares code for generation + +generate : parsed_output string ➔ string +> takes a root filename, it will be appended with ".s" and that will be the generated assembly file, +> the filename will not be consumed + +assemble : string ➔ _ +> takes a root filename, it will be appended with ".s" and that file will be compiled, +> the compiled output will be the given filename + +help : _ ➔ _ +> prints this help + +## Examples + +- compile the file "example.mol" into the "potato.s" assembly file +> `$ sugar example.mol lex parse potato generate` + +- compile the file "example.mol" into the "potato" executable +> `$ sugar example.mol lex parse potato generate assemble` + +- compile the file "example.mol" and "2.mol" into the "potato" executable +> `$ sugar example.mol lex 2.mol lex merge parse potato generate assemble` diff --git a/src/main.cpp b/src/main.cpp index 91752c2..0120cf9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,22 +81,31 @@ int main(int argc, char** argv) { system(link.str().c_str()); } else throw std::runtime_error("assemble expects an assembly file"); } else if(elem == "help" or elem == "--help") { - std::cout << "lex : string -> lexed_output\n"; - std::cout << "merge : lexed_output lexed_output -> lexed_output\n"; - std::cout << "parse : lexed_output -> parsed_output\n"; - std::cout << "generate : parsed_output string -> string\n"; - std::cout << "assemble : string -> \n"; - std::cout << "help : -> \n"; + std::cout << "# Sugar\n\n"; + std::cout << "## Commands\n\n"; + std::cout << "lex : string ➔ lexed_output\n"; + std::cout << "> takes a filename to a file that must be compiled\n\n"; + std::cout << "merge : lexed_output lexed_output ➔ lexed_output\n"; + std::cout << "> merges two lexed modules together\n\n"; + std::cout << "parse : lexed_output ➔ parsed_output\n"; + std::cout << "> prepares code for generation\n\n"; + std::cout << "generate : parsed_output string ➔ string\n"; + std::cout << "> takes a root filename, it will be appended with \".s\" and that will be the generated assembly file,\n"; + std::cout << "> the filename will not be consumed\n\n"; + std::cout << "assemble : string ➔ _ \n"; + std::cout << "> takes a root filename, it will be appended with \".s\" and that file will be compiled,\n"; + std::cout << "> the compiled output will be the given filename\n\n"; + std::cout << "help : _ ➔ _ \n"; + std::cout << "> prints this help\n\n"; + std::cout << "## Examples\n\n"; + std::cout << "- compile the file \"example.mol\" into the \"potato.s\" assembly file\n"; + std::cout << "> `$ sugar example.mol lex parse potato generate`\n"; std::cout << "\n"; - std::cout << "examples:\n"; - std::cout << "\tcompile the file \"example.mol\" into the \"potato.s\" assembly file\n"; - std::cout << "\t$ sugar example.mol lex parse potato generate\n"; + std::cout << "- compile the file \"example.mol\" into the \"potato\" executable\n"; + std::cout << "> `$ sugar example.mol lex parse potato generate assemble`\n"; std::cout << "\n"; - std::cout << "\tcompile the file \"example.mol\" into the \"potato\" executable\n"; - std::cout << "\t$ sugar example.mol lex parse potato generate assemble\n"; - std::cout << "\n"; - std::cout << "\tcompile the file \"example.mol\" and \"2.mol\" into the \"potato\" executable\n"; - std::cout << "\t$ sugar example.mol lex 2.mol lex merge parse potato generate assemble\n"; + std::cout << "- compile the file \"example.mol\" and \"2.mol\" into the \"potato\" executable\n"; + std::cout << "> `$ sugar example.mol lex 2.mol lex merge parse potato generate assemble`\n"; } else compile_stack.emplace(elem); }