regcomp.h 1.8 KB

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