7e160c3952d6aaa59e51103df9abed28d6ad9062
[idzebra-moved-to-github.git] / dfa / dfap.h
1 /*
2  * Copyright (C) 1994-1999, Index Data
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: dfap.h,v $
7  * Revision 1.8  1999-02-02 14:50:06  adam
8  * Updated WIN32 code specific sections. Changed header.
9  *
10  * Revision 1.7  1997/09/29 09:05:17  adam
11  * Thread safe DFA module. We simply had to put a few static vars to
12  * the DFA_parse structure.
13  *
14  * Revision 1.6  1997/09/18 08:59:17  adam
15  * Extra generic handle for the character mapping routines.
16  *
17  * Revision 1.5  1997/09/05 15:29:58  adam
18  * Changed prototype for chr_map_input - added const.
19  * Added support for C++, headers uses extern "C" for public definitions.
20  *
21  * Revision 1.4  1996/06/04 10:20:03  adam
22  * Added support for character mapping.
23  *
24  * Revision 1.3  1996/01/08  09:09:19  adam
25  * Function dfa_parse got 'const' string argument.
26  * New functions to define char mappings made public.
27  *
28  * Revision 1.2  1995/01/25  11:30:50  adam
29  * Simple error reporting when parsing regular expressions.
30  * Memory usage reduced.
31  *
32  * Revision 1.1  1995/01/24  16:02:53  adam
33  * New private header file in dfa module (dfap.h).
34  * Module no longer uses yacc to parse regular expressions.
35  *
36  */
37
38 #ifndef DFAP_H
39 #define DFAP_H
40
41 #include <dfa.h>
42
43 struct DFA_parse {
44     struct Tnode *root;       /* root of regular syntax tree */
45     int position;             /* no of positions so far */
46     int rule;                 /* no of rules so far */
47     BSetHandle *charset;      /* character set type */
48     BSet anyset;              /* character recognized by `.' */
49     int use_Tnode;            /* used Tnodes */
50     int max_Tnode;            /* allocated Tnodes */
51     struct Tblock *start;     /* start block of Tnodes */
52     struct Tblock *end;       /* end block of Tnodes */
53     int *charMap;
54     int charMapSize;
55     void *cmap_data;
56
57     unsigned look_ch;
58     int lookahead;
59     BSet look_chars;
60     int err_code;
61     int inside_string;
62     const unsigned char *expr_ptr;
63
64     struct Tnode **posar;
65
66     SetType poset;
67     Set *followpos;
68
69     const char **(*cmap)(void *vp, const char **from, int len);
70 };
71
72 typedef struct DFA_stateb_ {
73     struct DFA_stateb_ *next;
74     struct DFA_state *state_block;
75 } DFA_stateb;
76
77 struct DFA_states {
78     struct DFA_state *freelist;   /* chain of unused (but allocated) states */
79     struct DFA_state *unmarked;   /* chain of unmarked DFA states */
80     struct DFA_state *marked;     /* chain of marked DFA states */
81     DFA_stateb *statemem;         /* state memory */
82     int no;                       /* no of states (unmarked+marked) */
83     SetType st;                   /* Position set type */
84     int hash;                     /* no hash entries in hasharray */
85     struct DFA_state **hasharray; /* hash pointers */
86     struct DFA_state **sortarray; /* sorted DFA states */
87     struct DFA_trans *transmem;   /* transition memory */
88 };
89
90 int         init_DFA_states (struct DFA_states **dfasp, SetType st, int hash);
91 int         rm_DFA_states   (struct DFA_states **dfasp);
92 int         add_DFA_state   (struct DFA_states *dfas, Set *s,
93                              struct DFA_state **sp);
94 struct DFA_state *get_DFA_state  (struct DFA_states *dfas);
95 void        sort_DFA_states (struct DFA_states *dfas);
96 void        add_DFA_tran    (struct DFA_states *, struct DFA_state *,
97                              int, int, int);
98
99 #endif