regcomp.h 1.9 KB

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