/* main.C This is the main file for the tree property checker exit with 1 if error, or tree-prop not satisfied, otherwise 0. */ #include "treeprop.h" void out_of_store() { cerr << "tree-prop: 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. */ 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 cout << "Parsing in object in: " << Dem_input << "." << endl; Cd_graph* iCd_graph = new Cd_graph(); if ( ( Cd_graph* ) iCd_graph -> g_parse( Dem_input ) == NULL ) { cerr << "Parser error." << endl; exit(1); } cout << endl; /* compute the sets of alternation reachable vertices for each vertex in the class dictionary */ Ar_Vertex_list *ar_list = iCd_graph->compute_ar_sets(); #ifndef NOTRACE //#if 1 /* computes the sets of Alternation vertices and construction vertices then prints out the alternation reachable sets for each of the respective sets. This is nice information for debugging. */ Vertex_comma_list *adj = iCd_graph->alternation_vertices(); cout << "Alternation Vertices = "; adj->g_print(); cout << endl; adj->ar_print(ar_list); Vertex_comma_list *con = iCd_graph->construction_vertices(); cout << "Construction Vertices = "; con->g_print(); cout << endl; con->ar_print(ar_list); #else cout << "Alternation Reachable set for each alternation vertex:" << endl; Vertex_comma_list *adj = iCd_graph->alternation_vertices(); adj->ar_print(ar_list); #endif Vertex_comma_list *s = ar_list->compute_s_naught(); #ifndef NOTRACE //#if 1 cout << "S-naught = " ; s->g_print(); cout << endl << "s-naught ended" << endl; cout << "ar list = " << endl; ar_list->g_draw(); cout << endl << "end of ar list" << endl; #endif cout << endl << Dem_input ; int retval; if (retval = s->tree_prop(ar_list)) { cout << " satisfies the tree property." << endl; } else { cout << " does not satisfy the tree property" << endl; } return (retval); }