//----------------------------------------------------------------- // main.C //----------------------------------------------------------------- #include "UNKNOWN.h" void out_of_store() { cerr << "UNKNOWN: operator new failed, out of store\n"; exit( 1 ); } #ifndef __GNUC__ extern PF set_new_handler( PF ); #else extern "C" PF set_new_handler( PF ); #endif /* * 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. */ extern int _demeter_hash(const char* classname); int greeting = _demeter_hash("Greeting"); char* GEN_DIR = getenv( "GEN_DIR" ); int main( int argc, char* argv[], char* envp[] ) { // set new handler to catch out of memory exception set_new_handler( &out_of_store ); //---------------------------------------- // Parsing an object //---------------------------------------- // specify file to parse in const int MAXPATH = 256; char Dem_input[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 Cd_graph* iCd_graph = new Cd_graph(); if ( ( Cd_graph* ) iCd_graph -> g_parse( Dem_input ) == NULL ) { cerr << "Parser error." << endl; exit(1); } char* cdout = "cd.numbered-xref"; ofstream outputFile( cdout, ios::out ); if (outputFile) { iCd_graph->print_line_no(outputFile); } else { cout << "cd-numbered-xref error: unable to open " << cdout << " for output." << endl; exit( 1 ); } outputFile.close(); return ( 0 ); }