File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 11#define TEST 0
2+ #define CMD_COMPILER 1
23
34#include < iostream>
45#include < fstream>
910#include " Instr.hpp"
1011#include " Func.hpp"
1112#else
13+ #if CMD_COMPILER
14+ #include < sstream>
15+ #endif
1216#include " Parser.hpp"
1317#endif
1418
15- int main () {
19+ int main (int argc, const char * argv[] ) {
1620#if TEST
1721 Func* func = new Func (" _alpha_main" , new Scope (nullptr ));
1822
@@ -49,6 +53,26 @@ int main() {
4953 std::cout << " \t .ascii\t\" " << str << " \\ 0\" " << std::endl;
5054
5155 delete func;
56+ #elif CMD_COMPILER
57+ if (argc >= 2 ) {
58+ std::string filename (argv[1 ]);
59+ if (filename.length () > 5 ) {
60+ std::stringstream buf (filename);
61+ std::string basename;
62+ std::getline (buf, basename, ' .' );
63+
64+ std::ofstream output (basename + " .s" );
65+
66+ Parser p;
67+ Env* env = p.parse (filename);
68+ if (env)
69+ env->eval (output);
70+ } else {
71+ std::cerr << " Invalid input file" << std::endl;
72+ }
73+ } else {
74+ std::cerr << " No input file" << std::endl;
75+ }
5276#else
5377 std::ofstream output (" test.s" );
5478
You can’t perform that action at this time.
0 commit comments