From: Daniel Karbach Date: Sat, 15 Sep 2012 19:14:04 +0000 (+0200) Subject: generate header when output file ends with 'h' X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=fd4c31a00e232ac9e494d4cc00462b58af61198c;p=l2e.git generate header when output file ends with 'h' --- diff --git a/src/main.cpp b/src/main.cpp index 00fea98..edb0f1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,6 +36,7 @@ #include "sdl/InitSDL.h" #include +#include #include #include #include @@ -138,12 +139,23 @@ int main(int argc, char **argv) { switch (args.DetectRunLevel()) { case Arguments::COMPILE: { - 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: + case 'o': { + std::ofstream outstream(args.OutfilePath()); + Compiler(intp).Write(outstream); + break; + } + } return 0; } - case Arguments::DUMP: - { + case Arguments::DUMP: { std::cout << source << std::endl; return 0; }