regcomp.h 2.1 KB

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