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