annotate dfa.c @ 6:c61a7765c8f5 default tip

added COPYING to make the licence and copyrights clear.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 08 Mar 2012 11:08:07 +0900
parents 70e2c306231e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
1 #include "libguess.h"
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
2 #include "dfa.h"
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
3
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
4 boolean
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
5 dfa_alone(guess_dfa *dfa, guess_dfa *order[])
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
6 {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
7 int i;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
8
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
9 if (dfa->state < 0)
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
10 return FALSE;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
11
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
12 for (i = 0; order[i] != NULL; i++) {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
13 if (order[i] != dfa && order[i]->state >= 0) { //DFA_ALIVE()
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
14 return FALSE;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
15 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
16 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
17
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
18 return TRUE;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
19 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
20
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
21 boolean
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
22 dfa_none(guess_dfa *order[])
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
23 {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
24 int i;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
25
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
26 for (i = 0; order[i] != NULL; i++) {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
27 if (order[i]->state >= 0) { //DFA_ALIVE()
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
28 return FALSE;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
29 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
30 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
31
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
32 return TRUE;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
33 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
34
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
35 guess_dfa *
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
36 dfa_top(guess_dfa *order[])
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
37 {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
38 int i;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
39 guess_dfa *top = NULL;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
40 for (i = 0; order[i] != NULL; i++) {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
41 if (order[i]->state >= 0) { //DFA_ALIVE()
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
42 if (top == NULL || order[i]->score > top->score)
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
43 top = order[i];
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
44 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
45 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
46 return top;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
47 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
48
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
49 const char *
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
50 dfa_process(guess_dfa *order[], int c)
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
51 {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
52 int i;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
53 for (i = 0; order[i] != NULL; i++) {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
54 if (DFA_ALIVE_P(order[i])) {
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
55 if (dfa_alone(order[i], order))
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
56 return order[i]->name;
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
57 DFA_NEXT_P(order[i], c);
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
58 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
59
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
60 }
70e2c306231e - implemented dfa utility functions.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
diff changeset
61 }