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