IDZEBRA  2.2.7
dfa.h
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #ifndef DFA_H
21 #define DFA_H
22 
23 #include <bset.h>
24 #include <dfaset.h>
25 
26 #include <yaz/yconfig.h>
27 
28 YAZ_BEGIN_CDECL
29 
30 struct DFA_tran {
31  unsigned char ch[2]; /* transition on ch[0] <= c <= ch[1] to */
32  unsigned short to; /* this state */
33 };
34 
35 struct DFA_trans {
36  struct DFA_trans *next; /* next DFA transition block */
37  struct DFA_tran *tran_block; /* pointer to transitions */
38  int ptr; /* index of next transition in tran_block */
39  int size; /* allocated size of tran_block */
40 };
41 
42 struct DFA_state {
43  struct DFA_state *next; /* next entry in free/unmarked/marked list */
44  struct DFA_state *link; /* link to next entry in hash chain */
45  struct DFA_tran *trans; /* transition list */
46  DFASet set; /* set of positions (important nfa states) */
47  short no; /* no of this state */
48  short tran_no; /* no of transitions to other states */
49  short rule_no; /* if non-zero, this holds accept rule no */
50  short rule_nno; /* accept rule no - except start rules */
51 };
52 
53 struct DFA {
54  int no_states;
55  struct DFA_state **states;
58 };
59 
60 struct DFA *dfa_init (void);
61 void dfa_anyset_includes_nl(struct DFA *dfa);
62 void dfa_set_cmap (struct DFA *dfa, void *vp,
63  const char **(*cmap)(void *vp, const char **from, int len));
64 int dfa_parse (struct DFA *, const char **);
65 void dfa_mkstate (struct DFA *);
66 void dfa_delete (struct DFA **);
67 int dfa_get_last_rule (struct DFA *);
68 
69 void dfa_parse_cmap_clean (struct DFA *d);
70 void dfa_parse_cmap_new (struct DFA *d, const int *cmap);
71 void dfa_parse_cmap_del (struct DFA *d, int from);
72 void dfa_parse_cmap_add (struct DFA *d, int from, int to);
73 
74 extern int debug_dfa_trav;
75 extern int debug_dfa_tran;
76 extern int debug_dfa_followpos;
77 extern int dfa_verbose;
78 
79 extern unsigned short
82 
83 #define L_LP 1
84 #define L_RP 2
85 #define L_CHAR 3
86 #define L_CHARS 4
87 #define L_ANY 5
88 #define L_ALT 6
89 #define L_ANYZ 7
90 #define L_WILD 8
91 #define L_QUEST 9
92 #define L_CLOS1 10
93 #define L_CLOS0 11
94 #define L_END 12
95 #define L_START 13
96 
97 #define DFA_ERR_SYNTAX 1
98 #define DFA_ERR_LP 2
99 #define DFA_ERR_RP 3
100 
101 YAZ_END_CDECL
102 
103 #endif
104 /*
105  * Local variables:
106  * c-basic-offset: 4
107  * c-file-style: "Stroustrup"
108  * indent-tabs-mode: nil
109  * End:
110  * vim: shiftwidth=4 tabstop=8 expandtab
111  */
112 
void dfa_parse_cmap_add(struct DFA *d, int from, int to)
Definition: dfa.c:978
void dfa_parse_cmap_del(struct DFA *d, int from)
Definition: dfa.c:960
void dfa_anyset_includes_nl(struct DFA *dfa)
Definition: dfa.c:1104
unsigned short dfa_thompson_chars[]
unsigned short dfa_ccl_chars[]
Definition: dfa.h:81
void dfa_parse_cmap_new(struct DFA *d, const int *cmap)
Definition: dfa.c:940
int dfa_parse(struct DFA *, const char **)
Definition: dfa.c:1121
void dfa_mkstate(struct DFA *)
Definition: dfa.c:1148
void dfa_parse_cmap_clean(struct DFA *d)
Definition: dfa.c:926
void dfa_delete(struct DFA **)
Definition: dfa.c:1158
int debug_dfa_followpos
Definition: dfa.c:68
int debug_dfa_trav
Definition: dfa.c:66
int dfa_verbose
Definition: dfa.c:69
int debug_dfa_tran
Definition: dfa.c:67
void dfa_set_cmap(struct DFA *dfa, void *vp, const char **(*cmap)(void *vp, const char **from, int len))
Definition: dfa.c:1109
struct DFA * dfa_init(void)
Definition: dfa.c:1092
int dfa_get_last_rule(struct DFA *)
Definition: dfa.c:1116
Definition: dfap.h:31
Definition: dfa.h:42
short rule_no
Definition: dfa.h:49
struct DFA_state * link
Definition: dfa.h:44
short tran_no
Definition: dfa.h:48
short rule_nno
Definition: dfa.h:50
DFASet set
Definition: dfa.h:46
struct DFA_tran * trans
Definition: dfa.h:45
struct DFA_state * next
Definition: dfa.h:43
short no
Definition: dfa.h:47
Definition: dfa.h:30
unsigned short to
Definition: dfa.h:32
unsigned char ch[2]
Definition: dfa.h:31
Definition: dfa.h:35
struct DFA_trans * next
Definition: dfa.h:36
struct DFA_tran * tran_block
Definition: dfa.h:37
int ptr
Definition: dfa.h:38
int size
Definition: dfa.h:39
Definition: dfa.h:53
struct DFA_states * state_info
Definition: dfa.h:56
struct DFA_state ** states
Definition: dfa.h:55
struct DFA_parse * parse_info
Definition: dfa.h:57
int no_states
Definition: dfa.h:54