]> git.localhorst.tv Git - l2e.git/commitdiff
generate header when output file ends with 'h'
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 15 Sep 2012 19:14:04 +0000 (21:14 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 15 Sep 2012 19:45:56 +0000 (21:45 +0200)
src/main.cpp

index 00fea98dfba5506231f60141c4763b902a024fb6..edb0f1c8e47f28ca7361d32970a6e873e0b4f3ca 100644 (file)
@@ -36,6 +36,7 @@
 #include "sdl/InitSDL.h"
 
 #include <cstdlib>
+#include <cstring>
 #include <ctime>
 #include <exception>
 #include <iostream>
@@ -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;
                        }