55c74563ce92c8a23992d57c84120d5ddfc5f694
[idzebra-moved-to-github.git] / include / dfa.h
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: dfa.h,v $
7  * Revision 1.3  1995-01-24 16:01:30  adam
8  * Added -ansi to CFLAGS.
9  * New functions and change of data structures.
10  *
11  * Revision 1.2  1994/09/26  16:31:23  adam
12  * Minor changes. xmalloc declares xcalloc now.
13  *
14  * Revision 1.1  1994/09/26  10:17:43  adam
15  * Dfa-module header files.
16  *
17  */
18
19 #ifndef DFA_H
20 #define DFA_H
21
22 #include <bset.h>
23 #include <set.h>
24
25 struct DFA_tran {
26     unsigned char ch[2];      /* transition on ch[0] <= c <= ch[1] to */
27     unsigned short to;        /* this state */
28 };
29
30 struct DFA_trans {
31     struct DFA_trans *next;   /* next DFA transition block */
32     struct DFA_tran *tran_block; /* pointer to transitions */
33     int  ptr;                 /* index of next transition in tran_block */
34     int  size;                /* allocated size of tran_block */
35 };
36
37 struct DFA_state {
38     struct DFA_state *next;   /* next entry in free/unmarked/marked list */
39     struct DFA_state *link;   /* link to next entry in hash chain */
40     struct DFA_tran *trans;   /* transition list */
41     Set set;                  /* set of positions (important nfa states) */
42     short no;                 /* no of this state */
43     short tran_no;            /* no of transitions to other states */
44     short rule_no;            /* if non-zero, this holds accept rule no */
45 };
46
47 struct DFA {
48     int no_states;
49     struct DFA_state  **states;
50     struct DFA_states *state_info;
51     struct DFA_parse  *parse_info;
52 };
53
54 struct DFA *dfa_init (void);
55 int dfa_parse (struct DFA *, char **);
56 void dfa_mkstate (struct DFA *);
57 void dfa_delete (struct DFA **);
58
59 extern int  debug_dfa_trav;
60 extern int  debug_dfa_tran;
61 extern int  debug_dfa_followpos;
62 extern int  dfa_verbose;
63
64 extern unsigned short
65         dfa_thompson_chars[],
66         dfa_ccl_chars[];
67 #endif