// file: lxn_node_5.cc
//

// isip include files
//
#include "lex_node.h"
#include "lex_node_constants.h"

// method: num_nodes_cc
//
// arguments: none
//
// return: an int_4 with number of descendent nodes
//
// this method counts the number of the desecndant nodes for the
// current node
//
int_4 Lex_node::num_nodes_cc() {

  // number to count
  //
  int_4 numlx = (int_4)0;
  Link_node* nd = (Link_node*)NULL;
  Lex_node* lnd = (Lex_node*)NULL;

  // if there are children call recursively
  //
  if (child_d != (Link_list*)NULL) {
    for (nd = child_d->get_head_cc(); nd != (Link_node*)NULL;
	 nd = nd->get_next_cc()) {
      lnd = (Lex_node*)(nd->get_item_cc());
      numlx += lnd->num_nodes_cc();
    }
  }

  // increment count to include current node
  //
  numlx++;

  // return count and exit gracefully
  //
  return numlx;
}
