// file: $isip/class/pr/LanguageModelBNF/LanguageModelBNF.h // // make sure definitions are only made once // #ifndef ISIP_LANGUAGE_MODEL_BNF #define ISIP_LANGUAGE_MODEL_BNF #ifndef ISIP_LANGUAGE_MODEL_BASE #include #endif #ifndef ISIP_LANGUAGE_MODEL_UNDEFINED #include #endif // LanguageModelBase: defines the minimal interface contract for all // language model classes // class LanguageModelBNF : public LanguageModelBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //-------------------------------------------------------------- // // other important constants // //-------------------------------------------------------------- //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_BNF; static const int32 DEF_TAG; static const int32 MERGE_TYPE_LEN; //---------------------------------------- // // default values and arguments // //---------------------------------------- //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 100102; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // debug level // // inherited from LanguageModelBase // memory manager // static MemoryManager mgr_d; // rule model // RuleModel rm_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // method: diagnose // static bool8 diagnose(Integral::DEBUG level); // method: debug // bool8 debug(const unichar* msg) const; // constructor // LanguageModelBNF (); // method: read // bool8 read(Sof& sof, int32 tag = LanguageModelBNF::DEF_TAG, const String& cname = CLASS_NAME); // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // method: write // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const; // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: sofSize // int32 sofSize() const { return rm_d.sofSize(); } // method: assign // bool8 assign(const LanguageModelBNF& lmbnf); // method: operator= // bool8 operator=(const LanguageModelBNF& lmbnf); // method: eq // bool8 eq(const LanguageModelBNF& lmbnf) const; // method: operator== // bool8 operator==(const LanguageModelBNF& lmbnf) const; // method: clear // bool8 clear(Integral::CMODE ctype = Integral::RELEASE); //--------------------------------------------------------------------------- // // class-specific public methods required by interface contract // defined in LanguageModelBase.h // //--------------------------------------------------------------------------- // method: assign // bool8 assign(const LanguageModelBase& arg); // method: eq // bool8 eq(const LanguageModelBase& arg) const; // method: className // const String& className() const { return CLASS_NAME; } // method: getRuleModel // RuleModel getRuleModel() { return rm_d; } // method: setRuleModel // bool8 setRuleModel(const RuleModel& rm) { return rm_d.assign(rm); } //-------------------------------------------------------- // // other methods // //-------------------------------------------------------- // method: minimizeGraph // bool8 minimizeGraph(); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // method: mergeRules // bool8 mergeRules(ProductionRuleSet& rules, int32 index1, int32 index2); // method: isValidBNF // bool8 isValidBNF(ProductionRule rule); // method: isMergeType // bool8 isMergeType(ProductionRule rule); // method: detectFalseLoop // bool8 detectFalseLoop(String non_terminal1, String non_terminal2, ProductionRuleSet rules); // method: getRules // ProductionRuleSet getMergeTypeRules(String non_terminal, ProductionRuleSet rules); // method: findTerminals // Vector findTerminals(ProductionRuleSet rules_a, String rule_name_a); }; // end of include file // #endif