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