regcomp.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * substitution list
  3. */
  4. #define NSUBEXP 32
  5. typedef struct Resublist Resublist;
  6. struct Resublist
  7. {
  8. Resub m[NSUBEXP];
  9. };
  10. /*
  11. * Actions and Tokens (Reinst types)
  12. *
  13. * 02xx are operators, value == precedence
  14. * 03xx are tokens, i.e. operands for operators
  15. */
  16. #define RUNE 0177
  17. #define OPERATOR 0200 /* Bitmask of all operators */
  18. #define START 0200 /* Start, used for marker on stack */
  19. #define RBRA 0201 /* Right bracket, ) */
  20. #define LBRA 0202 /* Left bracket, ( */
  21. #define OR 0203 /* Alternation, | */
  22. #define CAT 0204 /* Concatentation, implicit operator */
  23. #define STAR 0205 /* Closure, * */
  24. #define PLUS 0206 /* a+ == aa* */
  25. #define QUEST 0207 /* a? == a|nothing, i.e. 0 or 1 a's */
  26. #define ANY 0300 /* Any character except newline, . */
  27. #define ANYNL 0301 /* Any character including newline, . */
  28. #define NOP 0302 /* No operation, internal use only */
  29. #define BOL 0303 /* Beginning of line, ^ */
  30. #define EOL 0304 /* End of line, $ */
  31. #define CCLASS 0305 /* Character class, [] */
  32. #define NCCLASS 0306 /* Negated character class, [] */
  33. #define END 0377 /* Terminate: match found */
  34. /*
  35. * regexec execution lists
  36. */
  37. #define LISTSIZE 10
  38. #define BIGLISTSIZE (25*LISTSIZE)
  39. typedef struct Relist Relist;
  40. struct Relist
  41. {
  42. Reinst* inst; /* Reinstruction of the thread */
  43. Resublist se; /* matched subexpressions in this thread */
  44. };
  45. typedef struct Reljunk Reljunk;
  46. struct Reljunk
  47. {
  48. Relist* relist[2];
  49. Relist* reliste[2];
  50. int starttype;
  51. Rune startchar;
  52. char* starts;
  53. char* eol;
  54. Rune* rstarts;
  55. Rune* reol;
  56. };
  57. extern Relist* _renewthread(Relist*, Reinst*, int, Resublist*);
  58. extern void _renewmatch(Resub*, int, Resublist*);
  59. extern Relist* _renewemptythread(Relist*, Reinst*, int, char*);
  60. extern Relist* _rrenewemptythread(Relist*, Reinst*, int, Rune*);