X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmain.cpp;h=8f19f435bfa25c3335222094c0ff01342d5066d4;hb=f6f1391a8af068bda8821310fceb762da8c12d67;hp=00fea98dfba5506231f60141c4763b902a024fb6;hpb=d557b3422756e3492b60cf545fd956a2fbf18af1;p=l2e.git diff --git a/src/main.cpp b/src/main.cpp index 00fea98..8f19f43 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,7 +26,6 @@ #include "graphics/Menu.h" #include "graphics/SimpleAnimation.h" #include "graphics/Sprite.h" -#include "loader/Compiler.h" #include "loader/Interpreter.h" #include "loader/ParsedSource.h" #include "loader/Parser.h" @@ -36,6 +35,7 @@ #include "sdl/InitSDL.h" #include +#include #include #include #include @@ -63,7 +63,6 @@ using graphics::Gauge; using graphics::Menu; using graphics::SimpleAnimation; using graphics::Sprite; -using loader::Compiler; using loader::Interpreter; using loader::ParsedSource; using loader::Parser; @@ -113,37 +112,26 @@ int main(int argc, char **argv) { ParsedSource source; 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(*i, source).Parse(); } -// 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(); - switch (args.DetectRunLevel()) { - case Arguments::COMPILE: + case Arguments::WRITE: { - std::ofstream testOut(args.OutfilePath()); - Compiler(intp).Write(testOut); + int length(std::strlen(args.OutfilePath())); + switch (args.OutfilePath()[length - 1]) { + case 'h': { + std::ofstream outstream(args.OutfilePath()); + source.WriteHeader(outstream); + break; + } + default: { + throw std::runtime_error(string("don't know how to write file ") + args.OutfilePath()); + } + } return 0; } - case Arguments::DUMP: - { + case Arguments::DUMP: { std::cout << source << std::endl; return 0; } @@ -151,6 +139,9 @@ int main(int argc, char **argv) { break; } + Interpreter intp(source); + intp.ReadSource(); + int battleResId(TypeDescription::GetTypeId("BattleResources")); int heroId(TypeDescription::GetTypeId("Hero")); int itemId(TypeDescription::GetTypeId("Item"));