/* Array of lookup_constraint_t */
typedef GArray * CandidateConstraints;
+typedef guint32 pinyin_option_t;
+
};
#endif
*/
+#include "pinyin_parser2.h"
#include <ctype.h>
#include <assert.h>
#include <string.h>
#include "stl_lite.h"
-#include "pinyin_parser2.h"
#include "pinyin_phrase2.h"
#include "pinyin_custom2.h"
#include "chewing_key.h"
using namespace pinyin;
-static bool check_pinyin_options(guint32 options, const pinyin_index_item_t * item) {
+static bool check_pinyin_options(pinyin_option_t options, const pinyin_index_item_t * item) {
guint32 flags = item->m_flags;
assert (flags & IS_PINYIN);
return true;
}
-static bool check_chewing_options(guint32 options, const chewing_index_item_t * item) {
+static bool check_chewing_options(pinyin_option_t options, const chewing_index_item_t * item) {
guint32 flags = item->m_flags;
assert (flags & IS_CHEWING);
return 0 > strcmp(lhs.m_pinyin_input, rhs.m_pinyin_input);
}
-static inline bool search_pinyin_index(guint32 options, const char * pinyin,
+static inline bool search_pinyin_index(pinyin_option_t options, const char * pinyin,
ChewingKey & key,
ChewingKeyRest & key_rest){
pinyin_index_item_t item;
return 0 > strcmp(lhs.m_chewing_input, rhs.m_chewing_input);
}
-static inline bool search_chewing_index(guint32 options, const char * chewing,
+static inline bool search_chewing_index(pinyin_option_t options, const char * chewing,
ChewingKey & key,
ChewingKeyRest & key_rest){
chewing_index_item_t item;
}
-bool FullPinyinParser2::parse_one_key (guint32 options, ChewingKey & key,
+bool FullPinyinParser2::parse_one_key (pinyin_option_t options, ChewingKey & key,
ChewingKeyRest & key_rest,
const char * pinyin, int len) const {
/* "'" are not accepted in parse_one_key. */
}
-int FullPinyinParser2::parse (guint32 options, ChewingKeyVector & keys,
+int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys,
ChewingKeyRestVector & key_rests,
const char *str, int len) const {
int i;
}
-bool FullPinyinParser2::post_process(guint32 options,
+bool FullPinyinParser2::post_process(pinyin_option_t options,
ChewingKeyVector & keys,
ChewingKeyRestVector & key_rests) const {
int i;
#define IS_KEY(x) (('a' <= x && x <= 'z') || x == ';')
-bool DoublePinyinParser2::parse_one_key(guint32 options, ChewingKey & key,
+bool DoublePinyinParser2::parse_one_key(pinyin_option_t options, ChewingKey & key,
ChewingKeyRest & key_rest,
const char *str, int len) const {
/* only 'a'-'z' and ';' are accepted here. */
-int DoublePinyinParser2::parse(guint32 options, ChewingKeyVector & keys,
+int DoublePinyinParser2::parse(pinyin_option_t options, ChewingKeyVector & keys,
ChewingKeyRestVector & key_rests,
const char *str, int len) const {
g_array_set_size(keys, 0);
}
-bool ChewingParser2::parse_one_key(guint32 options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const {
+bool ChewingParser2::parse_one_key(pinyin_option_t options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const {
char tone = CHEWING_ZERO_TONE;
int symbols_len = len;
/* only characters in chewing keyboard scheme are accepted here. */
-int ChewingParser2::parse(guint32 options, ChewingKeyVector & keys,
+int ChewingParser2::parse(pinyin_option_t options, ChewingKeyVector & keys,
ChewingKeyRestVector & key_rests,
const char *str, int len) const {
g_array_set_size(keys, 0);
#define PINYIN_PARSER2_H
#include <glib.h>
+#include "novel_types.h"
#include "chewing_key.h"
#include "pinyin_custom2.h"
*
* @return whether the entire string is parsed as one key.
*/
- virtual bool parse_one_key(guint32 options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const = 0;
+ virtual bool parse_one_key(pinyin_option_t options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const = 0;
/**
* @brief Translate the source string into a set of ChewingKeys.
/* Note:
* the parse method will use dynamic programming to drive parse_one_key.
*/
- virtual int parse(guint32 options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const = 0;
+ virtual int parse(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const = 0;
};
int final_step(size_t step_len, ChewingKeyVector & keys,
ChewingKeyRestVector & key_rests) const;
- bool post_process(guint32 options, ChewingKeyVector & keys,
+ bool post_process(pinyin_option_t options, ChewingKeyVector & keys,
ChewingKeyRestVector & key_rests) const;
public:
g_array_free(m_parse_steps, TRUE);
}
- virtual bool parse_one_key(guint32 options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const;
+ virtual bool parse_one_key(pinyin_option_t options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const;
- virtual int parse(guint32 options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const;
+ virtual int parse(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const;
};
virtual ~DoublePinyinParser2() {}
- virtual bool parse_one_key(guint32 options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const;
+ virtual bool parse_one_key(pinyin_option_t options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const;
- virtual int parse(guint32 options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const;
+ virtual int parse(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const;
public:
bool set_scheme(DoublePinyinScheme scheme);
virtual ~ChewingParser2() {}
- virtual bool parse_one_key(guint32 options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const;
+ virtual bool parse_one_key(pinyin_option_t options, ChewingKey & key, ChewingKeyRest & key_rest, const char *str, int len) const;
- virtual int parse(guint32 options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const;
+ virtual int parse(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const;
public:
bool set_scheme(ChewingScheme scheme);
/* compare pinyins with chewing internal representations. */
-inline int pinyin_compare_initial2(guint32 options,
+inline int pinyin_compare_initial2(pinyin_option_t options,
ChewingInitial lhs,
ChewingInitial rhs) {
if (lhs == rhs)
}
-inline int pinyin_compare_middle_and_final2(guint32 options,
+inline int pinyin_compare_middle_and_final2(pinyin_option_t options,
ChewingMiddle middle_lhs,
ChewingMiddle middle_rhs,
ChewingFinal final_lhs,
}
-inline int pinyin_compare_tone2(guint32 options,
+inline int pinyin_compare_tone2(pinyin_option_t options,
ChewingTone lhs,
ChewingTone rhs) {
if (lhs == rhs)
}
-inline int pinyin_compare_with_ambiguities2(guint32 options,
+inline int pinyin_compare_with_ambiguities2(pinyin_option_t options,
const ChewingKey * key_lhs,
const ChewingKey * key_rhs,
int phrase_length){
}
/* compute pinyin lower bound */
-inline void compute_lower_value2(guint32 options,
+inline void compute_lower_value2(pinyin_option_t options,
ChewingKey * in_keys,
ChewingKey * out_keys,
int phrase_length) {
}
/* compute pinyin upper bound */
-inline void compute_upper_value2(guint32 options,
+inline void compute_upper_value2(pinyin_option_t options,
ChewingKey * in_keys,
ChewingKey * out_keys,
int phrase_length) {