// file: $isip/class/mmedia/JSGFParser/jp_04.cc
// version: $Id: jp_04.cc 8929 2002-12-21 01:13:43Z alphonso $
//
// isip include files
//
#include "JSGFParser.h"

//-------------------------------------------------------------------------
//
// class-specified public methods
//
//-------------------------------------------------------------------------

// method: setExpression
//
// arguments:
//      1) String& expression_a: a single line of input grammar
//      2) long line_a: the number counting input grammar lines
//
// return: a boolean value indicating status
//
boolean JSGFParser::setExpression(String& expression_a) {

  // concat input expression line to the 
  //
  expression_d.concat(expression_a);

  // add new-line character
  //
  expression_d.concat(L"\n");

  // exit gracefully
  //
  return true;
}

// method: parseJSGF
//
// arguments:
//   const String& graph_start_a: (input) ISIP graph starting symbol
//   const String& graph_term_a: (input) ISIP graph terminal symbol
//
// return: a boolean value indicating status
//
boolean JSGFParser::parseJSGF(const String& graph_start_a,
			      const String& graph_term_a) {
  
  // set up ISIP graph ending symbols
  //
  graph_start_d.assign(graph_start_a);
  graph_term_d.assign(graph_term_a);
  
  // tokenize the JSGF grammar
  //
  getToken();

////////////////debug//////////////////////////////////////////
  for (long i = 0; i < token_vect_d.length(); i++) {
    JSGFToken t = token_vect_d(i);
    //t.printToken();
    //Console::put(L"**********************************");
  }
///////////////debug/////////////////////////////////////
    
  // parse and validate the tokenized JSGF grammar
  //
  parseGrammar();
    
  // insert each rule definition into the appropriate rule table
  //
  setRuleTables();

  // draw the DiGraph to represent the JSGF grammar
  //
  drawGraph();

  // exit gracefully
  //
  return true;
}









