]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Updated main to generate a scheme temp file, compile it, and then delete it
authorMike D. Lowis <mike@mdlowis.com>
Sat, 10 Mar 2012 20:51:27 +0000 (15:51 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Sat, 10 Mar 2012 20:51:27 +0000 (15:51 -0500)
source/main.cpp

index cf469b6c7c4010393b17b26b4f1aa6d69a041cb9..d53bad1e05bc794c5dd0ad37e74105876dcec06c 100644 (file)
@@ -18,32 +18,32 @@ int main(int argc, char** argv)
 
     if( (argc == 2) && fileExists( argv[1] ) )
     {
+        // Setup input and output files
         string input_fname(argv[1]);
         string temp_fname = createTempFileName( input_fname );
+
+        // Open input and output streams
         ifstream input(input_fname.c_str());
         ofstream output(temp_fname.c_str());
+
+        // Setup Parser and Visitors
         DLParser parser;
         Scheme printer(output);
         parser.input(new DLLexer(input));
-        parser.parse();
-        parser.process( printer );
 
-        //string input_fname(argv[1]);
-        //string temp_fname = createTempFileName( input_fname );
-        //ASTPrinter* visitor = NULL;
+        // Parse the input stream
+        parser.parse();
 
-        //// Open the input and output files
-        //ifstream input(input_fname.c_str());
+        // Post process the AST (converts to scheme and prints to output file)
+        parser.process( printer );
 
-        //// Parse the file
-        //parser.setInput(&input);
+        // Close the output file
+        output.close();
 
-        //// Translate the AST
-        //visitor = _new ASTPrinter( parser.parse() );
-        //visitor->visit();
+        // Compile the temporary file with chicken scheme
+        system( string("csc -O5 " + temp_fname).c_str() );
 
-        //// Write output to screen
-        //cout << visitor->str();
+        (void)remove( temp_fname.c_str() );
     }
     else
     {