PostgreSQL Source Code  git master
regexport.h
Go to the documentation of this file.
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-2024, 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 /* These macros must match corresponding ones in regguts.h: */
34 #define COLOR_WHITE 0 /* color for chars not appearing in regex */
35 #define COLOR_RAINBOW (-2) /* represents all colors except pseudocolors */
36 
37 /* information about one arc of a regex's NFA */
38 typedef struct
39 {
40  int co; /* label (character-set color) of arc */
41  int to; /* next state number */
42 } regex_arc_t;
43 
44 
45 /* Functions for gathering information about NFA states and arcs */
46 extern int pg_reg_getnumstates(const regex_t *regex);
47 extern int pg_reg_getinitialstate(const regex_t *regex);
48 extern int pg_reg_getfinalstate(const regex_t *regex);
49 extern int pg_reg_getnumoutarcs(const regex_t *regex, int st);
50 extern void pg_reg_getoutarcs(const regex_t *regex, int st,
51  regex_arc_t *arcs, int arcs_len);
52 
53 /* Functions for gathering information about colors */
54 extern int pg_reg_getnumcolors(const regex_t *regex);
55 extern int pg_reg_colorisbegin(const regex_t *regex, int co);
56 extern int pg_reg_colorisend(const regex_t *regex, int co);
57 extern int pg_reg_getnumcharacters(const regex_t *regex, int co);
58 extern void pg_reg_getcharacters(const regex_t *regex, int co,
59  pg_wchar *chars, int chars_len);
60 
61 #endif /* _REGEXPORT_H_ */
unsigned int pg_wchar
Definition: mbprint.c:31
int pg_reg_getnumoutarcs(const regex_t *regex, int st)
Definition: regexport.c:134
int pg_reg_getnumcolors(const regex_t *regex)
Definition: regexport.c:174
int pg_reg_getnumstates(const regex_t *regex)
Definition: regexport.c:36
int pg_reg_getfinalstate(const regex_t *regex)
Definition: regexport.c:64
int pg_reg_getinitialstate(const regex_t *regex)
Definition: regexport.c:50
void pg_reg_getoutarcs(const regex_t *regex, int st, regex_arc_t *arcs, int arcs_len)
Definition: regexport.c:155
int pg_reg_colorisend(const regex_t *regex, int co)
Definition: regexport.c:208
void pg_reg_getcharacters(const regex_t *regex, int co, pg_wchar *chars, int chars_len)
Definition: regexport.c:266
int pg_reg_getnumcharacters(const regex_t *regex, int co)
Definition: regexport.c:230
int pg_reg_colorisbegin(const regex_t *regex, int co)
Definition: regexport.c:191
Definition: regex.h:56
static char chars[TZ_MAX_CHARS]
Definition: zic.c:401