blob: a7d5943c97a648c2c9b4b6b35ebb293a172deddc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#include "libguess.h"
#include "dfa.h"
boolean
dfa_alone(guess_dfa *dfa, guess_dfa *order[])
{
int i;
if (dfa->state < 0)
return FALSE;
for (i = 0; order[i] != NULL; i++) {
if (order[i] != dfa && order[i]->state >= 0) { //DFA_ALIVE()
return FALSE;
}
}
return TRUE;
}
boolean
dfa_none(guess_dfa *order[])
{
int i;
for (i = 0; order[i] != NULL; i++) {
if (order[i]->state >= 0) { //DFA_ALIVE()
return FALSE;
}
}
return TRUE;
}
guess_dfa *
dfa_top(guess_dfa *order[])
{
int i;
guess_dfa *top = NULL;
for (i = 0; order[i] != NULL; i++) {
if (order[i]->state >= 0) { //DFA_ALIVE()
if (top == NULL || order[i]->score > top->score)
top = order[i];
}
}
return top;
}
const char *
dfa_process(guess_dfa *order[], int c)
{
int i;
for (i = 0; order[i] != NULL; i++) {
if (DFA_ALIVE_P(order[i])) {
if (dfa_alone(order[i], order))
return order[i]->name;
DFA_NEXT_P(order[i], c);
}
}
return NULL;
}
|