Header And Logo

PostgreSQL
| The world's most advanced open source database.

regexport.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * regexport.h
00004  *    Declarations for exporting info about a regex's NFA (nondeterministic
00005  *    finite automaton)
00006  *
00007  * The functions declared here provide accessors to extract the NFA state
00008  * graph and color character sets of a successfully-compiled regex.
00009  *
00010  * An NFA contains one or more states, numbered 0..N-1.  There is an initial
00011  * state, as well as a final state --- reaching the final state denotes
00012  * successful matching of an input string.  Each state except the final one
00013  * has some out-arcs that lead to successor states, each arc being labeled
00014  * with a color that represents one or more concrete character codes.
00015  * (The colors of a state's out-arcs need not be distinct, since this is an
00016  * NFA not a DFA.)  There are also "pseudocolors" representing start/end of
00017  * line and start/end of string.  Colors are numbered 0..C-1, but note that
00018  * color 0 is "white" (all unused characters) and can generally be ignored.
00019  *
00020  * Portions Copyright (c) 2013, PostgreSQL Global Development Group
00021  * Portions Copyright (c) 1998, 1999 Henry Spencer
00022  *
00023  * IDENTIFICATION
00024  *    src/include/regex/regexport.h
00025  *
00026  *-------------------------------------------------------------------------
00027  */
00028 #ifndef _REGEXPORT_H_
00029 #define _REGEXPORT_H_
00030 
00031 #include "regex/regex.h"
00032 
00033 /* information about one arc of a regex's NFA */
00034 typedef struct
00035 {
00036     int         co;             /* label (character-set color) of arc */
00037     int         to;             /* next state number */
00038 } regex_arc_t;
00039 
00040 
00041 /* Functions for gathering information about NFA states and arcs */
00042 extern int  pg_reg_getnumstates(const regex_t *regex);
00043 extern int  pg_reg_getinitialstate(const regex_t *regex);
00044 extern int  pg_reg_getfinalstate(const regex_t *regex);
00045 extern int  pg_reg_getnumoutarcs(const regex_t *regex, int st);
00046 extern void pg_reg_getoutarcs(const regex_t *regex, int st,
00047                   regex_arc_t *arcs, int arcs_len);
00048 
00049 /* Functions for gathering information about colors */
00050 extern int  pg_reg_getnumcolors(const regex_t *regex);
00051 extern int  pg_reg_colorisbegin(const regex_t *regex, int co);
00052 extern int  pg_reg_colorisend(const regex_t *regex, int co);
00053 extern int  pg_reg_getnumcharacters(const regex_t *regex, int co);
00054 extern void pg_reg_getcharacters(const regex_t *regex, int co,
00055                      pg_wchar *chars, int chars_len);
00056 
00057 #endif   /* _REGEXPORT_H_ */