comparison 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
comparison
equal deleted inserted replaced
1:04f2be1c8464 2:754a4550c64e
1 #ifndef __DFA_H__
2 #define __DFA_H__
3
4 /* data types */
5 typedef struct guess_arc_rec
6 {
7 unsigned int next; /* next state */
8 double score; /* score */
9 } guess_arc;
10
11 typedef struct guess_dfa_rec
12 {
13 signed char (*states)[256];
14 guess_arc *arcs;
15 int state;
16 double score;
17 } guess_dfa;
18
19 /* macros */
20 #define DFA_INIT(st, ar) \
21 { st, ar, 0, 1.0 }
22
23 #define DFA_NEXT(dfa, ch) \
24 do { \
25 int arc__; \
26 if (dfa.state >= 0) { \
27 arc__ = dfa.states[dfa.state][ch]; \
28 if (arc__ < 0) { \
29 dfa.state = -1; \
30 } else { \
31 dfa.state = dfa.arcs[arc__].next; \
32 dfa.score *= dfa.arcs[arc__].score; \
33 } \
34 } \
35 } while (0)
36
37 #define DFA_ALIVE(dfa) (dfa.state >= 0)
38
39 #endif