//---------------------------------------------------------------------------
#ifndef blif_parserH
#define blif_parserH
//---------------------------------------------------------------------------
#include "lexan_blif.h"
#include "hub/fsm.h"
//---------------------------------------------------------------------------
struct SubcktRecord {
  std::string model;
  std::string subcktName;
  std::string assigns;
};

class BlifParserClient {
public:
  virtual void endModel();
  virtual void haveModel(const std::string& modelName);
  virtual void haveInPorts(const std::list<std::string>& portNames);
  virtual void haveOutPorts(const std::list<std::string>& portNames);
  virtual void haveNames(std::list<std::string>& ports,std::list<std::string>& matrix);
  virtual void haveSubckt(std::list<SubcktRecord*>& subckt);
  virtual void haveKiss(int, int, std::list<hub::StateTableRow>&, std::string& resetState, int stateCount, int productCount);
  virtual void haveSearch (const std::string& fn);
  virtual ~BlifParserClient () {};
};
//---------------------------------------------------------------------------
class BlifParser {
private:

  BlifParserClient *client_;

  bool firstModel;
  std::string modelName;

  void model();
  void inputs();
  void outputs();
  void command();
  void names();
  void latch();
  void gate();
  void mlatch();
  void subckt();
  void startkiss();
  void search();

  std::list<SubcktRecord*> subcktRecords;
public:
  LexanBlif l;
  int token;

  void run(std::istream&, const std::string&);
  BlifParser(BlifParserClient *client): client_(client), firstModel(false) {}
  ~BlifParser() {}
};
//---------------------------------------------------------------------------
#endif
