From: Daniel Karbach Date: Sat, 15 Sep 2012 19:34:37 +0000 (+0200) Subject: added loader to main X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=0f30d8254ff8b9e63795960ec031577cf68fbf95;p=l2e.git added loader to main --- diff --git a/src/main.cpp b/src/main.cpp index f0811de..bdde265 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,7 @@ #include "graphics/Texture.h" #include "loader/Caster.h" #include "loader/Interpreter.h" +#include "loader/Loader.h" #include "loader/ParsedSource.h" #include "loader/Parser.h" #include "loader/TypeDescription.h" @@ -71,6 +72,7 @@ using math::Vector; using graphics::Texture; using loader::Caster; using loader::Interpreter; +using loader::Loader; using loader::ParsedSource; using loader::Parser; using loader::TypeDescription; @@ -140,8 +142,20 @@ int main(int argc, char **argv) { ParsedSource source; + Loader ld; + for (vector::const_iterator i(args.Infiles().begin()), end(args.Infiles().end()); i != end; ++i) { - Parser(*i, source).Parse(); + string filePath(*i); + switch (filePath[filePath.size() - 1]) { + case 'o': + ld.Load(filePath); + break; + case 's': + Parser(filePath, source).Parse(); + break; + default: + throw std::runtime_error("don't know what to do with " + filePath); + } } switch (args.GetRunLevel()) { @@ -154,6 +168,10 @@ int main(int argc, char **argv) { source.WriteHeader(outstream); break; } + case 'o': { + std::ofstream outstream(args.OutfilePath()); + Compiler(intp).Write(outstream); + break; default: { throw std::runtime_error(string("don't know how to write file ") + args.OutfilePath()); }