// class dictionary Cd_graph = Adj Adj_list. Adj = Vertex Neighbors ".". Neighbors: Construct | Alternat. Construct = "=" Any_vertex_list. Alternat = ":" Vertex "|" Vertex. Any_vertex : Labeled_vertex | Syntax_vertex. Syntax_vertex = String. Labeled_vertex = "<" Ident ">" Vertex. Adj_list: Cd_graph | Empty_cd_graph. Any_vertex_list: Nany_vertex_list | Empty. Nany_vertex_list = Any_vertex Any_vertex_list. Empty = . Empty_cd_graph = . Vertex = Ident. CountingVisitor = Integer. Main = . Cd_graph { traversal allInh(CountingVisitor c) { bypassing {-> *,vertex,*, => Neighbors, Construct} to Vertex; // is not elegant; should be: // *from* Cd_graph *via* Alternat *to* Vertex } } CountingVisitor { before Vertex (@ this.set_total(new Integer( total.intValue() + 1)) ; @) } Main { (@ static public void main(String args[]) throws Exception { Cd_graph graph = Cd_graph.parse(System.in); CountingVisitor count = new CountingVisitor(new Integer(0)); graph.allInh(count); System.out.println("Inheritance relationships " + count.get_total()); } @) } // class dictionary Cd_graph = < first > Adj < rest > Adj_list . Adj = < vertex > Vertex < ns > Neighbors "." . Neighbors : Construct | Alternat . Construct = "=" < c_ns > Any_vertex_list . Alternat = ":" < first > Vertex "|" < second > Vertex . Any_vertex : Labeled_vertex | Syntax_vertex . Syntax_vertex = < string > DemString . Labeled_vertex = "<" < label_name > DemIdent ">" < class_name > Vertex . Adj_list : Empty_cd_graph | Cd_graph . Any_vertex_list : Empty | Nany_vertex_list . Nany_vertex_list = < first > Any_vertex < rest > Any_vertex_list . Empty = . Empty_cd_graph = . Vertex = < name > DemIdent .