提交 aae1ba31 编写于 作者: dengyihao's avatar dengyihao

add fuzzy search

上级 9da56a41
......@@ -63,6 +63,10 @@ typedef struct {
FstRegex *regexCreate(const char *str);
uint32_t regexAutomStart(FstRegex *regex);
bool regexAutomIsMatch(FstRegex *regex, uint32_t state);
bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null);
bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result);
// void regexSetup(FstRegex *regex, uint32_t size, const char *str);
// uint32_t regexStart()
......
......@@ -35,3 +35,27 @@ FstRegex *regexCreate(const char *str) {
regex->dfa = dfaBuilderBuild(builder);
return regex;
}
uint32_t regexAutomStart(FstRegex *regex) {
///// no nothing
return 0;
}
bool regexAutomIsMatch(FstRegex *regex, uint32_t state) {
if (regex->dfa != NULL && dfaIsMatch(regex->dfa, state)) {
return true;
} else {
return false;
}
}
bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null) {
// make frame happy
return null;
}
bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result) {
if (regex->dfa == NULL) {
return false;
}
return dfaAccept(regex->dfa, state, byte, result);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册