07051bb2cbf2a2d5f1452f66cc66e6fa9431bf36
[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.5  1997-09-05 15:29:58  adam
8  * Changed prototype for chr_map_input - added const.
9  * Added support for C++, headers uses extern "C" for public definitions.
10  *
11  * Revision 1.4  1996/06/04 10:20:03  adam
12  * Added support for character mapping.
13  *
14  * Revision 1.3  1996/01/08  09:09:19  adam
15  * Function dfa_parse got 'const' string argument.
16  * New functions to define char mappings made public.
17  *
18  * Revision 1.2  1995/01/25  11:30:50  adam
19  * Simple error reporting when parsing regular expressions.
20  * Memory usage reduced.
21  *
22  * Revision 1.1  1995/01/24  16:02:53  adam
23  * New private header file in dfa module (dfap.h).
24  * Module no longer uses yacc to parse regular expressions.
25  *
26  */
27
28 #ifndef DFAP_H
29 #define DFAP_H
30
31 #include <dfa.h>
32
33 struct DFA_parse {
34     struct Tnode *root;       /* root of regular syntax tree */
35     int position;             /* no of positions so far */
36     int rule;                 /* no of rules so far */
37     BSetHandle *charset;      /* character set type */
38     BSet anyset;              /* character recognized by `.' */
39     int use_Tnode;            /* used Tnodes */
40     int max_Tnode;            /* allocated Tnodes */
41     struct Tblock *start;     /* start block of Tnodes */
42     struct Tblock *end;       /* end block of Tnodes */
43     int *charMap;
44     int charMapSize;
45     const char **(*cmap)(const char **from, int len);
46 };
47
48 typedef struct DFA_stateb_ {
49     struct DFA_stateb_ *next;
50     struct DFA_state *state_block;
51 } DFA_stateb;
52
53 struct DFA_states {
54     struct DFA_state *freelist;   /* chain of unused (but allocated) states */
55     struct DFA_state *unmarked;   /* chain of unmarked DFA states */
56     struct DFA_state *marked;     /* chain of marked DFA states */
57     DFA_stateb *statemem;         /* state memory */
58     int no;                       /* no of states (unmarked+marked) */
59     SetType st;                   /* Position set type */
60     int hash;                     /* no hash entries in hasharray */
61     struct DFA_state **hasharray; /* hash pointers */
62     struct DFA_state **sortarray; /* sorted DFA states */
63     struct DFA_trans *transmem;   /* transition memory */
64 };
65
66 int         init_DFA_states (struct DFA_states **dfasp, SetType st, int hash);
67 int         rm_DFA_states   (struct DFA_states **dfasp);
68 int         add_DFA_state   (struct DFA_states *dfas, Set *s,
69                              struct DFA_state **sp);
70 struct DFA_state *get_DFA_state  (struct DFA_states *dfas);
71 void        sort_DFA_states (struct DFA_states *dfas);
72 void        add_DFA_tran    (struct DFA_states *, struct DFA_state *,
73                              int, int, int);
74
75 #endif