// Check to see if each Alternative Term of an alternation production // is not a repetition class and that it is not duplicately defined in // inherited alternation classes. *operation* int check_alternatives() *init* (@ 1 @) *traverse* *from* Cd_graph *through* ->Alternat_ns,*,Term_Bar_list *to-stop* Term *carry* *in* Vertex* src = (@ this->get_source() @) *along* *from* Adjacency *to* Term *carry* *in* Term_Bar_list* tbl = (@ this @) *along* *from* Term_Bar_list *to* Term *carry* *in* Cd_graph* graph = (@ this @) *along* *from* Cd_graph *to* Term *wrapper* Cd_graph *prefix* (@ cout << endl << "Checking that all alternatives are defined " << "as either" << endl << "\tconstruction classes or alternation classes that" << endl << "\twill eventually be defined by " << "construction classes ..." << endl; @) *wrapper* Term *prefix* (@ Adjacency* adjclass = graph->find_adjacency(this->get_vertex()); if (adjclass->check_alternatives1()) { cout << "sem-check: error: on line " << this->find_line_number() << " "; this->get_vertex()->g_print(); cout << ", a repetition class," << endl << "\tcannot be an alternative of "; src->g_print(); cout << "." << endl; return_val = 0; } if (adjclass->check_alternatives2(graph, src, tbl)) { return_val = 0; } @) // Check to see if this adjacency is a repetition class. *operation* int check_alternatives1() *init* (@ 0 @) *traverse* *from* Adjacency *to-stop* Repetit_n *wrapper* Repetit_n *prefix* (@ return_val = 1; @) // Check to see if an alternative is duplicated. *operation* int check_alternatives2(Cd_graph* graph, Vertex* src, Term_Bar_list* tbl) *init* (@ 0 @) *traverse* *from* Adjacency *through* ->Alternat_ns,*,Term_Bar_list *to-stop* Term *wrapper* Term *prefix* (@ if (tbl->check_alternatives3(src, this->get_vertex())) return_val = 1; else if (graph->find_adjacency(this->get_vertex()) ->check_alternatives2(graph, src, tbl)) return_val = 1; @) *operation* int check_alternatives3(Vertex* src, Vertex* v) *init* (@ 0 @) *traverse* *from* Term_Bar_list *to-stop* Term *wrapper* Term *prefix* (@ if (this->get_vertex()->g_equal(v)) { cout << "sem-check: error: on line " << this->find_line_number() << " "; this->get_vertex()->g_print(); cout << "is duplicated as an alternative of "; src->g_print(); cout << "." << endl; return_val = 1; } @)