📄 jsgftoken.h
字号:
// file: JSGFToken.h//// make sure definitions are only made once//#ifndef ISIP_JSGF_TOKEN#define ISIP_JSGF_TOKEN// isip include files//#ifndef ISIP_CHAR#include <Char.h>#endif#ifndef ISIP_STRING#include <String.h>#endif#ifndef ISIP_FLOAT#include <Float.h>#endif#ifndef ISIP_LONG#include <Long.h>#endif// Token: a class to store a tokenized component of JSGF grammar//class JSGFToken { //-------------------------------------------------------- // // public constants // //--------------------------------------------------------public: // define the class name // static const String CLASS_NAME; // constants: i/o related constants // static const long DEF_TOKEN_TYPE; static const String DEF_HEADER; static const String DEF_KEYWORD; static const String DEF_GRAMMAR_NAME; static const String DEF_IMPORT_GRAMMAR; static const String DEF_RULENAME; static const String DEF_TERMINAL; static const String DEF_OPERATOR; static const String DEF_TAG; static const String DEF_TERM_RULE_NAME; static const float DEF_WEIGHT; static const long DEF_TERM_ROW; static const long DEF_TERM_COL; static const long DEF_VERTEX_INDEX; static const boolean DEF_IS_HEAD_GROUP; static const boolean DEF_WEIGHTED_TERMINAL; //---------------------------------------- // // error codes // //---------------------------------------- static const long ERR = (long)50200; //------------------------------------------------------------- // // protected data // //-------------------------------------------------------------public: // numeric value identifying the token's type // 0: header // 1: keyword // 2: grammar name // 3: import grammar name // 4: rule name // 5: terminal // 6: tag // 7: quoted token // 8: weight // 9: operator // 10: parser-defined marker // long token_type_d; // self-identifying header // String header_d; // keyword (public) // String keyword_d; // grammar name // String grammar_name_d; // import grammar // String import_grammar_d; // refernce to a rule in surrounding <> // String rulename_d; // a speakable terminal token // String terminal_d; // operators // String operator_d[2]; // tag string surrounded by {} // String tag_d; // weight of the token // float weight_d; // term_row: the index of the queue containing this terminal (row) // long term_row_d; // term_rule_name: the name of the rule containing this terminal (row) // String term_rule_name_d; // term_col: the index of this terminal in the queue (column) // long term_col_d; // vertex_index: the index of this terminal in the symbol vertex list // long vertex_index_d; // is_head_group: flag to determine if the token is optional group // boolean is_head_group_d; // weight flag indicating if a weight is assigned to the token // boolean weighted_terminal_d; // static memory manager // static MemoryManager mgr_d; //-------------------------------------------------------- // // required public methods // //--------------------------------------------------------public: // method: name // static const String& name() { return CLASS_NAME; } // method: diagnose // static boolean diagnose(Integral::DEBUG level_a); // method: debug // boolean debug(const unichar* msg_a) const; // method: destructor // ~JSGFToken() {}; // method: constructor // JSGFToken(); // method: assign // boolean assign(const JSGFToken& arg_a); // method: operator= // JSGFToken& operator=(const JSGFToken& arg_a) { assign(arg_a); return *this; } // method: eq // boolean eq(const JSGFToken& arg_a) const; // method: operator== // boolean operator==(const JSGFToken& arg_a) { return eq(arg_a); } // method: read // boolean read(Sof& sof, long tag, const String& cname = CLASS_NAME) { return Error::handle(name(), L"read", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: write // boolean write(Sof& sof, long tag, const String& cname = CLASS_NAME) const { return Error::handle(name(), L"write", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static boolean setGrowSize(long grow_size) { return mgr_d.setGrow(grow_size); } // method: clear // boolean clear(Integral::CMODE ctype_a); //-------------------------------------------------------- // // class-specified public methods // //--------------------------------------------------------public: // method: setToken // boolean setToken(const String& arg_a); // method: setVertexIndex // boolean setVertexIndex(const long vertex_index_a); // method: setRuleName // boolean setRuleName(const String& rule_name_a); // method: setMarker // boolean setMarker(const String& marker_a, const JSGFToken& name_a); // method: printToken // boolean printToken(); // method: getTerminal // String getTerminal() { return terminal_d; } // method: setCoordinate // boolean setCoordinate(long row_a, long col_a); // method: setTerminalWeight // boolean setTerminalWeight(JSGFToken& arg_a); //-------------------------------------------------------- // // private methods // //--------------------------------------------------------private: // method: isHeader // boolean isHeader(const String& arg_a); // method: isKeyword // boolean isKeyword(const String& arg_a); // method: isGrammarName // boolean isGrammarName(const String& arg_a); // method: isImportGrammar // boolean isImportGrammar(const String& arg_a); // method: isRulename // boolean isRulename(const String& arg_a); // method: isTerminal // boolean isTerminal(const String& arg_a); // method: isOperator // boolean isOperator(const String& arg_a); // method: isTag // boolean isTag(const String& arg_a); // method: isQuotedToken // boolean isQuotedToken(const String& arg_a); // method: isWeight // boolean isWeight(const String& arg_a);};// end of file//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -