]> granicus.if.org Git - postgresql/blob - src/include/regex/regexport.h
Phase 2 of pgindent updates.
[postgresql] / src / include / regex / regexport.h
1 /*-------------------------------------------------------------------------
2  *
3  * regexport.h
4  *        Declarations for exporting info about a regex's NFA (nondeterministic
5  *        finite automaton)
6  *
7  * The functions declared here provide accessors to extract the NFA state
8  * graph and color character sets of a successfully-compiled regex.
9  *
10  * An NFA contains one or more states, numbered 0..N-1.  There is an initial
11  * state, as well as a final state --- reaching the final state denotes
12  * successful matching of an input string.  Each state except the final one
13  * has some out-arcs that lead to successor states, each arc being labeled
14  * with a color that represents one or more concrete character codes.
15  * (The colors of a state's out-arcs need not be distinct, since this is an
16  * NFA not a DFA.)      There are also "pseudocolors" representing start/end of
17  * line and start/end of string.  Colors are numbered 0..C-1, but note that
18  * color 0 is "white" (all unused characters) and can generally be ignored.
19  *
20  * Portions Copyright (c) 2013-2017, PostgreSQL Global Development Group
21  * Portions Copyright (c) 1998, 1999 Henry Spencer
22  *
23  * IDENTIFICATION
24  *        src/include/regex/regexport.h
25  *
26  *-------------------------------------------------------------------------
27  */
28 #ifndef _REGEXPORT_H_
29 #define _REGEXPORT_H_
30
31 #include "regex/regex.h"
32
33 /* information about one arc of a regex's NFA */
34 typedef struct
35 {
36         int                     co;                             /* label (character-set color) of arc */
37         int                     to;                             /* next state number */
38 } regex_arc_t;
39
40
41 /* Functions for gathering information about NFA states and arcs */
42 extern int      pg_reg_getnumstates(const regex_t *regex);
43 extern int      pg_reg_getinitialstate(const regex_t *regex);
44 extern int      pg_reg_getfinalstate(const regex_t *regex);
45 extern int      pg_reg_getnumoutarcs(const regex_t *regex, int st);
46 extern void pg_reg_getoutarcs(const regex_t *regex, int st,
47                                   regex_arc_t *arcs, int arcs_len);
48
49 /* Functions for gathering information about colors */
50 extern int      pg_reg_getnumcolors(const regex_t *regex);
51 extern int      pg_reg_colorisbegin(const regex_t *regex, int co);
52 extern int      pg_reg_colorisend(const regex_t *regex, int co);
53 extern int      pg_reg_getnumcharacters(const regex_t *regex, int co);
54 extern void pg_reg_getcharacters(const regex_t *regex, int co,
55                                          pg_wchar *chars, int chars_len);
56
57 #endif                                                  /* _REGEXPORT_H_ */