regexport.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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-2016, 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. #include "regex/regex.h"
  31. /* information about one arc of a regex's NFA */
  32. typedef struct
  33. {
  34. int co; /* label (character-set color) of arc */
  35. int to; /* next state number */
  36. } regex_arc_t;
  37. /* Functions for gathering information about NFA states and arcs */
  38. extern int pg_reg_getnumstates(const regex_t *regex);
  39. extern int pg_reg_getinitialstate(const regex_t *regex);
  40. extern int pg_reg_getfinalstate(const regex_t *regex);
  41. extern int pg_reg_getnumoutarcs(const regex_t *regex, int st);
  42. extern void pg_reg_getoutarcs(const regex_t *regex, int st,
  43. regex_arc_t *arcs, int arcs_len);
  44. /* Functions for gathering information about colors */
  45. extern int pg_reg_getnumcolors(const regex_t *regex);
  46. extern int pg_reg_colorisbegin(const regex_t *regex, int co);
  47. extern int pg_reg_colorisend(const regex_t *regex, int co);
  48. extern int pg_reg_getnumcharacters(const regex_t *regex, int co);
  49. extern void pg_reg_getcharacters(const regex_t *regex, int co,
  50. pg_wchar *chars, int chars_len);
  51. #endif /* _REGEXPORT_H_ */