/*
 *      DEMETER System Version 5.0
 *      Copyright (c) 1993 Northeastern University
 *
 */

#include <iostream.h>
#include <stdlib.h>
#include <string.h>

#include "UNKNOWN.h"

/*
 * GEN_DIR is a global variable containing the path of the generation 
 * environment. This path is used to find the cd-print and cd-parse 
 * class dictionaries. 
 * Do NOT delete the following statement.
 */

char* GEN_DIR = getenv( "GEN_DIR" );


int main( int argc, char* argv[], char* envp[] )
{
  if (GEN_DIR == NULL)
     GEN_DIR = "./scanner/";

  //----------------------------------------
  // Parsing an object 
  //----------------------------------------
  // specify file to parse in 
  const int MAXPATH = 256;
  char Dem_input[MAXPATH], Dem_input2[MAXPATH];

  // Input file is first argument
  if( argc == 2 ) {
     strcpy( Dem_input, argv[1] );
   }
  else {
     strcpy( Dem_input, "demeter-input" );  // default input 
  }

  // parse it in 
  cout << "Parsing in object in: " << Dem_input << "." << endl;
  ProgramInput* iProgramInput = new ProgramInput();
  if ((ProgramInput*) iProgramInput->g_parse(Dem_input) == NULL) {
     cerr << "Parser error." << endl;
     exit(1);
  }
  cout << endl;    

  RoutingAlgorithm* iRoutingAlgorithm = iProgramInput->build();
  iRoutingAlgorithm->iterate();

  return ( 0 );
}

