X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=00fea98dfba5506231f60141c4763b902a024fb6;hb=d557b3422756e3492b60cf545fd956a2fbf18af1;hp=2ac04233370a496f7cf469ceb5963a9f33578a25;hpb=d04fc494f1a140c20941d0d871f2b6a074068b44;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index 2ac0423..00fea98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ */ #include "app/Application.h" +#include "app/Arguments.h" #include "app/Input.h" #include "battle/BattleState.h" #include "battle/Hero.h" @@ -38,10 +39,12 @@ #include #include #include +#include #include #include using app::Application; +using app::Arguments; using app::Input; using battle::BattleState; using battle::Hero; @@ -73,6 +76,8 @@ using std::cerr; using std::cout; using std::endl; using std::exception; +using std::string; +using std::vector; int main(int argc, char **argv) { const int width = 800; @@ -102,18 +107,49 @@ int main(int argc, char **argv) { Stats::CreateTypeDescription(); common::TargetingMode::CreateTypeDescription(); + Arguments args; + args.Read(argc, argv); + ParsedSource source; - Parser("test-data/test.l2s", source).Parse(); - Parser("test-data/ikaris.l2s", source).Parse(); - Parser("test-data/items.l2s", source).Parse(); - Parser("test-data/spells.l2s", source).Parse(); - Parser("test-data/constants.l2s", source).Parse(); + + for (vector::const_iterator i(args.Infiles().begin()), end(args.Infiles().end()); i != end; ++i) { + string filePath(*i); + switch (filePath[filePath.size() - 1]) { + case 'o': + // TODO: load object file + break; + case 's': + Parser(filePath, source).Parse(); + break; + default: + throw std::runtime_error("don't know what to do with " + filePath); + } + } + +// Parser("test-data/test.l2s", source).Parse(); +// Parser("test-data/ikaris.l2s", source).Parse(); +// Parser("test-data/items.l2s", source).Parse(); +// Parser("test-data/spells.l2s", source).Parse(); +// Parser("test-data/constants.l2s", source).Parse(); + Interpreter intp(source); intp.ReadSource(); -// std::ofstream testOut("test-data/test.l2o"); -// Compiler(intp).Write(testOut); -// return 0; + switch (args.DetectRunLevel()) { + case Arguments::COMPILE: + { + std::ofstream testOut(args.OutfilePath()); + Compiler(intp).Write(testOut); + return 0; + } + case Arguments::DUMP: + { + std::cout << source << std::endl; + return 0; + } + case Arguments::PLAY: + break; + } int battleResId(TypeDescription::GetTypeId("BattleResources")); int heroId(TypeDescription::GetTypeId("Hero"));