// Expand inherited classes. *operation* int expand_inherit(char* filename) *init* (@ 1 @) *wrapper* Cd_graph *prefix* (@ cout << endl << "Expanding inherit classes ..." << endl; if (filename != NULL) { filebuf in_file; if (in_file.open(filename, input) != 0) cout << "sem-check: " << filename << " recreated." << endl; else in_file.close(); ofstream OutFile(filename); if (!OutFile) { cout << "sem-check: error: cannot open file " << filename << endl; return_val = 0; } else { OutFile << "// Inherit-class-expanded class dictionary." << endl << endl; } this->expand_inherit1(); this->expand_inherit5(); this->expand_inherit9(); this->g_print(OutFile); OutFile.close(); } else { this->expand_inherit1(); this->expand_inherit5(); this->expand_inherit9(); } @) // Expand and create implicit inheritance edges for all alternation parts *operation* void expand_inherit1() *traverse* *from* Cd_graph *to* Alternat_ns *carry* *in* Cd_graph* graph = (@ this @) *along* *from* Cd_graph *to* Alternat_ns *carry* *in* Vertex* v = (@ this->get_source() @) *along* *from* Adjacency *to* Alternat_ns *wrapper* Alternat_ns *prefix* (@ this->expand_inherit2(graph, v); @) *operation* void expand_inherit2(Cd_graph* graph, Vertex* v) *traverse* *from* Alternat_ns *through* ->Alternat_ns,alternat_ns,* *to* Term *wrapper* Term *prefix* (@ Adjacency* adjclass = graph->find_adjacency(this->get_vertex()); adjclass->expand_inherit3(graph, v); @) *operation* void expand_inherit3(Cd_graph* graph, Vertex* v) *traverse* *from* Adjacency *to* {Construct_ns, Alternat_ns, Inherit_term} *carry* *inout* Inherit_term* it *along* *from* Adjacency *to* Inherit_term //, Labeled, Regular, Regular_syntax, // Print_indent, Print_unindent, Print_skip, Print_space, // Optional_term} *wrapper* Adjacency *prefix* (@ it = NULL; @) *wrapper* {Construct_ns, Alternat_ns} *suffix* (@ if (it == NULL) { it = new Inherit_term; this->get_construct_ns()->append(it); Normal* t = new Normal; t->set_vertex((Vertex*)v->g_copy()); t->set_moduleRef(new LocalRef); t->set_actual_parameters(NULL); it->set_inherited(new Term_Comma_list); it->get_inherited()->append(t); } else if (!it->expand_inherit4(v)) { Normal* t = new Normal; t->set_vertex((Vertex*)v->g_copy()); t->set_moduleRef(new LocalRef); t->set_actual_parameters(NULL); it->get_inherited()->append(t); } @) *wrapper* Inherit_term *prefix* (@ it = this; @) // Search for vertex already in inheritance list *operation* int expand_inherit4(Vertex* v) *init* (@ 0 @) *traverse* *from* Inherit_term *to* Vertex *wrapper* Vertex *prefix* (@ if (this->g_equal(v)) return_val = 1; @) *operation* void expand_inherit5() *traverse* *from* Cd_graph *to* Inherit_term *carry* *in* Cd_graph* graph = (@ this @) *along* *from* Cd_graph *to* Inherit_term *carry* *in* Neighbors_wc* ns = (@ this @) *along* *from* Neighbors_wc *to* Inherit_term *carry* *in* Vertex* src = (@ this->get_source() @) *along* *from* Adjacency *to* Inherit_term *wrapper* Inherit_term *prefix* (@ this->expand_inherit6(graph, ns, src->get_vertex_name()->get_line_number()); @) *wrapper* {Construct_ns, Alternat_ns} *suffix* (@ Any_vertex_List *avl = this->expand_inherit8(); this->get_construct_ns()->g_delete(); this->set_construct_ns(avl); @) *operation* void expand_inherit6(Cd_graph* graph, Neighbors_wc* ns, int line_num) *traverse* *from* Inherit_term *to* Term *wrapper* Term *prefix* (@ Adjacency* adjclass = graph->find_adjacency(this->get_vertex()); adjclass->expand_inherit7(graph, ns, line_num); @) *operation* void expand_inherit7(Cd_graph* graph, Neighbors_wc* ns, int line_num) *traverse* *from* Adjacency *to-stop* {Labeled, Regular, Inherit_term, Optional_term, Print_indent, Print_unindent, Print_skip, Print_space, Regular_syntax} *wrapper* {Print_indent, Print_unindent, Print_skip, Print_space, Regular_syntax} *prefix* (@ Any_vertex* av = (Any_vertex*)this->g_copy(); ns->get_construct_ns()->append(av); @) *wrapper* Regular *prefix* (@ Any_vertex* av = (Any_vertex*)this->g_copy(); this->get_vertex()->expand_inherit10(line_num); ns->get_construct_ns()->append(av); @) *wrapper* Labeled *prefix* (@ Any_vertex* av = (Any_vertex*)this->g_copy(); this->get_label_name()->set_line_number(line_num); this->get_vertex()->expand_inherit10(line_num); ns->get_construct_ns()->append(av); @) *wrapper* Optional_term *prefix* (@ Any_vertex* av = (Any_vertex*)this->g_copy(); this->expand_inherit11(line_num); ns->get_construct_ns()->append(av); @) *wrapper* Inherit_term *prefix* (@ this->expand_inherit6(graph, ns, line_num); @) *operation* Any_vertex_List* expand_inherit8() *init* (@ new Any_vertex_List @) *traverse* *from* Neighbors_wc *to-stop* {Regular, Labeled, Optional_term, Inherit_term, Print_indent, Print_unindent, Print_skip, Print_space, Regular_syntax} *wrapper* {Regular, Labeled, Optional_term, Regular_syntax, Print_indent, Print_unindent, Print_skip, Print_space} *prefix* (@ return_val->append((Any_vertex*)this->g_copy()); @) // Delete all common parts *operation* void expand_inherit9() *traverse* *from* Cd_graph *to* Alternat_ns *wrapper* Alternat_ns *prefix* (@ Any_vertex_List *avl = new Any_vertex_List; this->get_construct_ns()->g_delete(); this->set_construct_ns(avl); if (this->get_common() == NULL) this->set_common(new Common); @) *operation* void expand_inherit10(int line_num) *traverse* *from* Term *to* Vertex *wrapper* Vertex *prefix* (@ this->get_vertex_name()->set_line_number(line_num); @) *operation* void expand_inherit11(int line_num) *traverse* *from* Optional_term *to* {Vertex, Labeled} *wrapper* Vertex *prefix* (@ this->get_vertex_name()->set_line_number(line_num); @) *wrapper* Labeled *prefix* (@ this->get_label_name()->set_line_number(line_num); @)