Listing 3: SimpleCalculator.cpp

#include <string>
#include <iostream>
#include "CommandLine.h"
#include "Calculator.tab.h"
#include "BisonWorkarounds.h"

std::string
GetVersion()
{  return "1.20-calculator";
}

int main(int argc, char* argv[])
{
  try
  {
    tools::CommandLine commands(argc, argv);
    
    if( commands.Exists("version") )
    {  
      std::cout << "Simple Calculator version: " <<
            GetVersion() << std::endl;
      exit(0);
    }

    if( commands.Exists("yydebug") )
    {   yydebug = 1;
    }
    yyparse( reinterpret_cast<void*>( &commands ) );
  }
  catch( std::string& strCommandLineError )
  {
    std::cout << "Simple Calculator error: " <<
       strCommandLineError << std::endl;
    exit(1);
  }
  return 0;
}
— End of Listing —