From tsun Mon Nov 29 10:51:47 1993 Return-Path: Received: from matterhorn.ccs.neu.edu by amber.ccs.neu.edu (4.1/SMI-4.1) id AA29877; Mon, 29 Nov 93 10:51:46 EST Date: Mon, 29 Nov 93 10:51:46 EST From: Thangaraj Veerappan Message-Id: <9311291551.AA29877@amber.ccs.neu.edu> To: lieber Subject: cdnumber utility Status: R Prof. Lieberherr, The following contains the cd for cds(modified), propagation pattern (for determining line numbers) and the cdnumber script that prints out the cd numbered. The original source is in ~tsun/proj-l which I'll make readable. -Thangaraj ******cd for cds (modified heart of demeter) :::::::::::::: cd.cd :::::::::::::: Demeter_in = Input. Input : Cd_graph *common*. Ll1SetElement = [ DemString] [ TEpsilon] [ TClassTerminal] [ TEndOfFile]. Cd_graph = < adjacencies > Nlist(Adjacency) [ "*dfs_n*" DemNumber ] [ "*current_component*" DemNumber ] . Vertices_With_Same_Fset = "*pool*" List(Vertex). Adjacency = < source > Vertex ["(" < parameters> Comma_list(Vertex) ")"] < ns > Neighbors ["*treated*" DemNumber] ["*imm_ancester*" Vertex ] ["*inherited_Any_vertex*" List(Any_vertex) ] ["*expanded_common_parts*" List(Common_parts) ] ["*associated*" List(Adjacency) "." ] [ "*dfs*" DemNumber ] [ "*high*" DemNumber ] [ "*scc*" DemNumber ] [ "( firstset" Comma_list(Ll1SetElement) ")"] [ "( followset" Comma_list(Ll1SetElement) ")"] "." . Common_parts = "*common parts*" Adjacency "*is*" List(Any_vertex). Neighbors : Neighbors_wc | Repetit_n *common*. Neighbors_wc : Construct_ns | Alternat_ns *common* < construct_ns > List(Any_vertex). Construct_ns = "=". Alternat_ns = ":" < alternat_ns > Bar_list(Term) [ Common] ["*emptycommon*" DemNumber]. Common = "*common*". Repetit_n = "~" Sandwich(Kernel). Kernel = [ Term ] "{" Sandwich(Term) "}". Any_vertex : Opt_labeled_term | Optional_term | Syntax_vertex | Inherit_term *common* [ "*origin*" Adjacency "." ]. Vertex = < vertex_name > DemIdent . Syntax_vertex : Regular_syntax | Print_command *common*. Regular_syntax = < string > DemString . Print_command : Print_indent | Print_unindent | Print_skip | Print_space *common*. Print_indent = "+" . Print_unindent = "-" . Print_skip = "*l" . Print_space = "*s" . Opt_labeled_term : Labeled | Regular *common* [StaticSpec] [AccessorSpec] Term. StaticSpec = "*static*" . AccessorSpec : ReadOnlyAcc | PrivateAcc *common* . ReadOnlyAcc = "*read-only*" . PrivateAcc = "*private*" . Regular = . Labeled = "<" < label_name > DemIdent ">" . Inherit_term = "*inherit*" Comma_list(Term). Term : Normal | CppTerm *common* Vertex TermRef ["*adjacency*" Adjacency "." ] ["(" Comma_list(Term) ")" ] [ "(firstset" Comma_list(Ll1SetElement) ")"] [ "(followset" Comma_list(Ll1SetElement) ")"] . CppTerm = "$" . Normal = . TermRef : LocalRef | ModuleRef. ModuleRef : CompRef | LibRef *common* DemIdent. LocalRef = . CompRef = "@". LibRef = "@@". Optional_term = "[" Sandwich(Opt_labeled_term) "]". TEpsilon = "*epsilon*" . TEndOfFile = "*eof*" . TClassTerminal = "*classterminal*" DemIdent . List(S) ~ {S}. Nlist(S) ~ S {S}. Bar_list(S) ~ S {"|" S}. Comma_list(S) ~ S {"," S}. Sandwich(S) = List(Syntax_vertex) S List(Syntax_vertex) [ "( firstset" Comma_list(Ll1SetElement) ")"] [ "( followset" Comma_list(Ll1SetElement) ")"] . ****Propagation pattern that prints out the line numbers of classes into a file cdoutfile :::::::::::::: line.pp :::::::::::::: *operation* void print_line_no(ostream& strm) *traverse* *from* Cd_graph *through* -> *,source,* *to* Vertex *carry* *in* Cd_graph* c *along* *from* Cd_graph *to* Vertex *at* Cd_graph c =(@ this @) *wrapper* Vertex *prefix* (@ this->g_print(strm); strm << "\t:" << this->get_vertex_name()->get_line_number() << "\t"; c->print_line_used(this,strm); strm << "\n";@) *operation* void print_line_used(Vertex* v,ostream& strm) *traverse* *from* Cd_graph *bypassing* -> *,source,* *to* Vertex *wrapper* Vertex *prefix* (@ if (this->g_equal(v)) { strm << this->get_vertex_name()->get_line_number() << "\t"; } @) :::::::::::::: main.C (includes my changes) :::::::::::::: //----------------------------------------------------------------- // main.C.sample // This file is an example for a main.C Demeter main file. // It provides sample code fragments showing how to use some of the // Demeter runtime libraries. To have a quick test of your environment // rename this file to main.C and compile the environment. //----------------------------------------------------------------- #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. */ 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 << ". \n"; 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; //---------------------------------------- // Drawing an object //---------------------------------------- cout << "Drawing the parsed object:\n"; iCd_graph -> g_draw(); cout << "\nEnd of drawing.\n" << endl; //---------------------------------------- // Copying an object //---------------------------------------- cout << "Copying the object.\n"; Cd_graph* nCd_graph = ( Cd_graph* ) iCd_graph -> g_copy(); cout << endl; //---------------------------------------- // Displaying the copied object as a tree //---------------------------------------- cout << "Displaying the copied object as a tree:\n"; nCd_graph -> g_displayAsTree(); cout << "\nEnd of display.\n" << endl; //---------------------------------------- // Comparing two objects //---------------------------------------- cout << "Comparing the two objects:\n"; if ( iCd_graph -> g_equal( nCd_graph ) == 1 ) cout << "copied and original object are equal\n" << endl; else cout << "copied and original object are NOT equal\n" << endl; //---------------------------------------- // Printing an object //---------------------------------------- cout << "Pretty printing the parsed object:\n"; char* tmp_filename = "notmod/tmp/demeter-output"; ofstream outFile( tmp_filename ); if ( !outFile ) { cerr << "UNKNOWN error: unable to open " << tmp_filename << " for output" << endl; exit( 1 ); } cout << iCd_graph << endl; iCd_graph -> g_print( outFile ); outFile.close(); cout << "\nEnd of printing.\n" << endl; //---------------------------------------- // Selftest of generic parser/printer //---------------------------------------- cout << "Selftest of generic parser/printer:\n"; Cd_graph* iCd_graph_printed = new Cd_graph(); iCd_graph_printed = (Cd_graph*)iCd_graph_printed->g_parse( tmp_filename ); if( iCd_graph->g_equal( iCd_graph_printed ) == 1 ) { cout << "g_parse and g_parse( g_print( g_parse ) ) are equal.\n" << "Selftest passed.\n"; } else { cout << "g_parse and g_parse( g_print( g_parse ) ) are NOT equal.\n" << "Selftest failed.\n"; } cout << endl; //---------------------------------------- // Your own code follows after this //---------------------------------------- char* cdout = "cdoutfile"; ofstream outputFile (cdout); if (outputFile) iCd_graph->print_line_no(outputFile); else cout << "error opening cdoutfile\n"; outputFile.close(); cout << "\n*** FINISHED ***" << endl; return ( 0 ); } ***** Shell script to be invoked after "make". It takes in a filename as argument. (It does check to see if the filename is provided) :::::::::::::: cdnumber :::::::::::::: #cleanup yes|rm -f cdoutfile cd_tmpfile #run run $1 nl -ba $1 echo "" echo "******FINISHED*******" echo "" #sort sort cdoutfile > cd_tmpfile fold -75 cd_tmpfile ******Steps to run the cdnumber utility******** 1. sem-check (with the above cd.cd. sem-check passes) 2. dmkmf 3. make 4. cdnumber [filename] where [filename] contains the cd to be numbered.