From 9f17bdefd4303242d017f2cd3e0ee3bfba819af2 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 23 Nov 2011 15:18:49 +0800 Subject: begin to write chewing parser2 --- scripts/genbopomofoheader.py | 2 ++ src/storage/pinyin_parser2.cpp | 4 +++- src/storage/pinyin_parser2.h | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/genbopomofoheader.py b/scripts/genbopomofoheader.py index 2ed613e..a609589 100644 --- a/scripts/genbopomofoheader.py +++ b/scripts/genbopomofoheader.py @@ -89,6 +89,7 @@ def gen_chewing_symbols(scheme): string = '"{0}"'.format(string) entry = "{{{0: <5}, {1}}}".format(key, string) entries.append(entry) + entries.append("{'\\0', NULL}") return ",\n".join(entries) @@ -105,6 +106,7 @@ def gen_chewing_tones(scheme): key = escape_char(key); entry = "{{{0: <5}, {1}}}".format(key, tone) entries.append(entry) + entries.append("{'\\0', 0}") return ",\n".join(entries) diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 16af6b3..b54e7f2 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -503,7 +503,9 @@ int DoublePinyinParser2::parse (guint32 options, ChewingKeyVector & keys, int parsed_len = 0; while (parsed_len < maximum_len) { const char * cur_str = str + parsed_len; - i = std_lite::min(maximum_len - parsed_len, max_double_pinyin_length); + i = std_lite::min(maximum_len - parsed_len, + (int)max_double_pinyin_length); + ChewingKey key; ChewingKeyRest key_rest; for (; i > 0; --i) { bool success = parse_one_key(options, key, key_rest, cur_str, i); diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index 869f3c6..b81240e 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -75,7 +75,7 @@ typedef struct { typedef struct { const char m_input; - const char m_tone; + const char m_tone; } chewing_tone_item_t; typedef GArray * ChewingKeyVector; @@ -195,9 +195,17 @@ public: */ class ChewingParser2 : public PinyinParser2 { - /* Note: one internal pointer to chewing scheme table. */ + /* Note: some internal pointers to chewing scheme table. */ +protected: + chewing_symbol_item_t * m_symbol_table; + chewing_tone_item_t * m_tone_table; public: + ChewingParser2() { + m_symbol_table = NULL; m_tone_table = NULL; + set_scheme(CHEWING_DEFAULT); + } + virtual ~ChewingParser2() {} virtual bool parse_one_key(guint32 options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const; -- cgit