codekingpro/portable-devtools
115k
1/*-------------------------------------------------------------------------2 *3 * regexport.h4 * Declarations for exporting info about a regex's NFA (nondeterministic5 * finite automaton)6 *7 * The functions declared here provide accessors to extract the NFA state8 * 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 initial11 * state, as well as a final state --- reaching the final state denotes12 * successful matching of an input string. Each state except the final one13 * has some out-arcs that lead to successor states, each arc being labeled14 * 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 an16 * NFA not a DFA.) There are also "pseudocolors" representing start/end of17 * line and start/end of string. Colors are numbered 0..C-1, but note that18 * color 0 is "white" (all unused characters) and can generally be ignored.19 *20 * Portions Copyright (c) 2013-2023, PostgreSQL Global Development Group21 * Portions Copyright (c) 1998, 1999 Henry Spencer22 *23 * IDENTIFICATION24 * src/include/regex/regexport.h25 *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 */38typedef struct39{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 */46extern int pg_reg_getnumstates(const regex_t *regex);47extern int pg_reg_getinitialstate(const regex_t *regex);48extern int pg_reg_getfinalstate(const regex_t *regex);49extern int pg_reg_getnumoutarcs(const regex_t *regex, int st);50extern 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 */54extern int pg_reg_getnumcolors(const regex_t *regex);55extern int pg_reg_colorisbegin(const regex_t *regex, int co);56extern int pg_reg_colorisend(const regex_t *regex, int co);57extern int pg_reg_getnumcharacters(const regex_t *regex, int co);58extern void pg_reg_getcharacters(const regex_t *regex, int co,59 pg_wchar *chars, int chars_len);60 61#endif /* _REGEXPORT_H_ */62 