diff --git a/Main.cpp b/Main.cpp index 07e1619..3a5a394 100644 --- a/Main.cpp +++ b/Main.cpp @@ -1,9 +1,37 @@ #include "code_writer.hpp" #include +#include +namespace fs = std::filesystem; int main(int argc, char const *argv[]) { - code_writer toassembly(argv[1]); + lots_of_files files; + std::string input(argv[1]); + if (fs::is_directory(input)) + { + files.push_back(input); + for (auto &entry : fs::directory_iterator(input)) + { + if (entry.path().extension() == ".vm") + { + std::string vmfile = entry.path().string(); + if (entry.path().filename() == "Sys.vm") + { + files.insert(files.begin() + 1, vmfile); + } + else + { + files.push_back(vmfile); + } + } + } + } + else + { + files.push_back(input); + } + + code_writer toassembly(files); toassembly.write_assembly(); return 0; }