From: Mike D. Lowis Date: Sat, 10 Mar 2012 20:51:27 +0000 (-0500) Subject: Updated main to generate a scheme temp file, compile it, and then delete it X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=eae54fee493c6d0ad0f8d3c4276ca122ea8aa536;p=archive%2Fdlang.git Updated main to generate a scheme temp file, compile it, and then delete it --- diff --git a/source/main.cpp b/source/main.cpp index cf469b6..d53bad1 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -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 {