//Determine if there are any classes that are not defined. //When a class is not defined in the class dictionary //we will get the following error message: // ClassName is an UNDEFINED CLASS //In this phase, our program also checks for non-unique parts, phaseI. UndefinedVisitor{ (@ HashSet allClasses = new HashSet(); HashSet terminals = new HashSet(); //////////////////////////// HashSet getHashSet(){ return allClasses; } /////////////////////////// void setTerminalsHash(){ terminals.add("Ident"); terminals.add("Graph"); terminals.add("Text"); terminals.add("Word"); terminals.add("Line"); terminals.add("AroundContinuation"); } /////////////////////////// HashSet getTerminalHash(){ terminals.clear(); setTerminalsHash(); return terminals; } ////////////////////////// void before (Vertex host){ allClasses.add(host.get_vertex_name().toString()); } @) } Cd_graph{ (@ //Method for determining if a part class is actually defined void Undef_Classes_Check(){ TraversalGraph aClasses = new TraversalGraph("from Cd_graph bypassing Neighbors to Vertex", Main.cg); TraversalGraph pClasses = new TraversalGraph("from Cd_graph bypassing {-> *, superclass, *} through Neighbors to Vertex", Main.cg); //Get the vertex names of the defined classes UndefinedVisitor uv1 = new UndefinedVisitor(); aClasses.traverse(this, uv1); HashSet allClasses = uv1.getHashSet(); //Get the vertex names of the part classes UndefinedVisitor uv2 = new UndefinedVisitor(); pClasses.traverse(this, uv2); Iterator partClasses = uv2.getHashSet().iterator(); while(partClasses.hasNext()){ String vName = (String)partClasses.next(); HashSet terms = uv2.getTerminalHash(); //Ensure that the class is not a Terminal class before declaring it Undefined!!! if((!allClasses.contains(vName)) && (!terms.contains(vName))){ System.out.println(vName + " is an UNDEFINED CLASS"); System.exit(1); } } } @) }