8fe3e32ddc2e3a4befacef8ff942fdefcd31bf85
[idzebra-moved-to-github.git] / dfa / dfap.h
1 /* $Id: dfap.h,v 1.13 2006-05-10 08:13:18 adam Exp $
2    Copyright (C) 1995-2005
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra.  If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21 */
22
23
24
25 #ifndef DFAP_H
26 #define DFAP_H
27
28 #include <dfa.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 struct DFA_parse {
35     struct Tnode *root;       /* root of regular syntax tree */
36     int position;             /* no of positions so far */
37     int rule;                 /* no of rules so far */
38     BSetHandle *charset;      /* character set type */
39     BSet anyset;              /* character recognized by `.' */
40     int use_Tnode;            /* used Tnodes */
41     int max_Tnode;            /* allocated Tnodes */
42     struct Tblock *start;     /* start block of Tnodes */
43     struct Tblock *end;       /* end block of Tnodes */
44     int *charMap;
45     int charMapSize;
46     void *cmap_data;
47
48     unsigned look_ch;
49     int lookahead;
50     BSet look_chars;
51     int err_code;
52     int inside_string;
53     const unsigned char *expr_ptr;
54
55     struct Tnode **posar;
56
57     DFASetType poset;
58     DFASet *followpos;
59
60     const char **(*cmap)(void *vp, const char **from, int len);
61 };
62
63 typedef struct DFA_stateb_ {
64     struct DFA_stateb_ *next;
65     struct DFA_state *state_block;
66 } DFA_stateb;
67
68 struct DFA_states {
69     struct DFA_state *freelist;   /* chain of unused (but allocated) states */
70     struct DFA_state *unmarked;   /* chain of unmarked DFA states */
71     struct DFA_state *marked;     /* chain of marked DFA states */
72     DFA_stateb *statemem;         /* state memory */
73     int no;                       /* no of states (unmarked+marked) */
74     DFASetType st;                   /* Position set type */
75     int hash;                     /* no hash entries in hasharray */
76     struct DFA_state **hasharray; /* hash pointers */
77     struct DFA_state **sortarray; /* sorted DFA states */
78     struct DFA_trans *transmem;   /* transition memory */
79 };
80
81 int         init_DFA_states (struct DFA_states **dfasp, DFASetType st, int hash);
82 int         rm_DFA_states   (struct DFA_states **dfasp);
83 int         add_DFA_state   (struct DFA_states *dfas, DFASet *s,
84                              struct DFA_state **sp);
85 struct DFA_state *get_DFA_state  (struct DFA_states *dfas);
86 void        sort_DFA_states (struct DFA_states *dfas);
87 void        add_DFA_tran    (struct DFA_states *, struct DFA_state *,
88                              int, int, int);
89
90 #ifdef __cplusplus
91 }
92 #endif
93 #endif
94 /*
95  * Local variables:
96  * c-basic-offset: 4
97  * indent-tabs-mode: nil
98  * End:
99  * vim: shiftwidth=4 tabstop=8 expandtab
100  */
101