Mercurial > libguess
view dfa.h @ 2:754a4550c64e
- added arabic, greek, hebrew and turkish DFAs
- new UCS-2LE/BE DFAs
- now arabic_impl.c uses arabic DFAs
- dfa common macros have been moved to dfa.h
- minor cleanups
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Wed, 11 Jun 2008 00:11:30 +0900 |
parents | |
children | 70e2c306231e |
line wrap: on
line source
#ifndef __DFA_H__ #define __DFA_H__ /* data types */ typedef struct guess_arc_rec { unsigned int next; /* next state */ double score; /* score */ } guess_arc; typedef struct guess_dfa_rec { signed char (*states)[256]; guess_arc *arcs; int state; double score; } guess_dfa; /* macros */ #define DFA_INIT(st, ar) \ { st, ar, 0, 1.0 } #define DFA_NEXT(dfa, ch) \ do { \ int arc__; \ if (dfa.state >= 0) { \ arc__ = dfa.states[dfa.state][ch]; \ if (arc__ < 0) { \ dfa.state = -1; \ } else { \ dfa.state = dfa.arcs[arc__].next; \ dfa.score *= dfa.arcs[arc__].score; \ } \ } \ } while (0) #define DFA_ALIVE(dfa) (dfa.state >= 0) #endif