regcomp.h 2.2 KB

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