#include <string>
#include <iostream>
#include "HelperRoutines.h"
#include "ExtendedCommands.h"
std::string
GetVersion()
{ return "1.10-ProcessDriver";
}
void
Usage()
{
std::cout << std::endl <<
"ProcessDriver version " << GetVersion() <<
", built on 03 December 2001." << std::endl << std::endl <<
"Usage: ProcessDriver -file input_file " <<
"-child child_program [-trace_grammar]"
<< std::endl << " [-show_intermediate_files] [-yydebug]"
<< std::endl;
}
int main(int argc, char* argv[])
{
std::string childProgram;
std::string inputFile;
try
{
using namespace out_of_band_example;
ExtendedCommands commands( argc, argv);
if( ! commands.GetOption("child_program", "child",
childProgram) )
{
childProgram = GetEnv("CHILD_PROCESS");
if( childProgram.length() == 0 )
{ childProgram = "SimpleCalculator";
}
else
{ childProgram = CombinePathAndFile(childProgram,
"SimpleCalculator");
}
}
if( commands.Exists("version") )
{
childProgram += " -version";
std::cout << "ProcessDriver version: " << GetVersion()
<< std::endl;
}
else
{
if( ! commands.GetOption("file", "f", inputFile ) )
{ throw(std::string("ProcessDriver: -file is required."));
}
childProgram += commands
.SynthesizeOptionString("file","f" );
childProgram += commands
.SynthesizeOptionString("show_intermediate_results",
"show" );
childProgram += commands
.SynthesizeOptionString("trace_grammar", "t" );
childProgram += commands
.SynthesizeOptionString("yydebug", "y" );
}
FeedFileToSubprogram( inputFile, childProgram, commands );
}
catch( std::string& strCommandLineError )
{
Usage();
exit(10);
}
return 0;
}
End of Listing