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