// file: $isip/class/asr/JSGFParser/jp_00.cc
// version: $Id: jp_00.cc 8323 2002-07-10 14:49:57Z wang $
//

// isip include files
//
#include "JSGFParser.h"
 
//------------------------------------------------------------------------
//
// required public methods
//
//-----------------------------------------------------------------------

// method: default constructor
//
// arguments: none
//
// return: none
//
JSGFParser::JSGFParser() {

  // initialize class data:
  //  note that debug_level_d is initialized by default.
  //
  expression_d.assign(L"");
  graph_start_d = DEF_GRAPH_START;
  graph_term_d = DEF_GRAPH_TERM;
  grammar_name_d = DEF_GRAMMAR_NAME;
  vertex_list_index_d = 0;
}

// method: assign
//
// arguments:
//  const JSGFParser& arg: (input) object to assign
//
// return: a boolean value indicating status
//
// this method assigns the input object to current object
//
boolean JSGFParser::assign(const JSGFParser& arg_a) {

  // assign all protected data
  //
  expression_d.assign(arg_a.expression_d);
  graph_d = arg_a.graph_d;
  token_vect_d = arg_a.token_vect_d;
  final_d = arg_a.final_d;
  symbol_list_d = arg_a.symbol_list_d;
  graph_start_d = arg_a.graph_start_d;
  graph_term_d = arg_a.graph_term_d;
  grammar_name_d = arg_a.grammar_name_d;
  vertex_list_index_d = arg_a.vertex_list_index_d;

  // gracefully exit
  //
  return true;
}

// method: eq
//
// arguments:
//  const JSGFParser& arg: (input) input object to assign
//
// return: a boolean value indicating status
//
// this method checks whether the current object is identical to the
// input object
//
boolean JSGFParser::eq(const JSGFParser& arg_a) const {

  // compare all protected data
  //
  if(!graph_d.eq(arg_a.graph_d)) {
    return false;
  }

  if(!expression_d.eq(arg_a.expression_d, true)) {
      return false;
  }
 
  if(!token_vect_d.eq(arg_a.token_vect_d)) {
      return false;
  }

  if(!final_d.eq(arg_a.final_d))
    return false;

  if(!symbol_list_d.eq(arg_a.symbol_list_d))
    return false;
  
  if(!graph_start_d.eq(arg_a.graph_start_d))
    return false;

  if(!graph_term_d.eq(arg_a.graph_term_d))
    return false;

  if(!grammar_name_d.eq(arg_a.grammar_name_d))
    return false;
  
  // gracefully exit
  //
  return true;
}

// method: clear
//
// arguments:
//  Integral::CMODE ctype: (input) clear mode
//
// return: a boolean value indicating status
//
// this method resets the data members to the default values
//
boolean JSGFParser::clear(Integral::CMODE ctype_a) {

  // reset all protected data
  //
  if (ctype_a != Integral::RETAIN) {
    expression_d.assign(L"");
    graph_start_d = DEF_GRAPH_START;
    graph_term_d = DEF_GRAPH_TERM;
    grammar_name_d = DEF_GRAMMAR_NAME;
  }
  // gracefully exit
  //
  return true;
}

//-------------------------------------------------------------------------
//
// we define non-integral constants in the default constructor
//      
//-------------------------------------------------------------------------
  
// constants: class name
//
const String JSGFParser::CLASS_NAME(L"JSGFParser");

// constants: i/o related constants
//
const String JSGFParser::DEF_GRAPH_START(L"S");
const String JSGFParser::DEF_GRAPH_TERM(L"T");
const String JSGFParser::DEF_GRAMMAR_NAME(L"");

// static instantiations: memory manager
//
MemoryManager JSGFParser::mgr_d(sizeof(JSGFParser), JSGFParser::name());
