regexp9.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef _REGEXP9H_
  2. #define _REGEXP9H_ 1
  3. #include <utf.h>
  4. typedef struct Resub Resub;
  5. typedef struct Reclass Reclass;
  6. typedef struct Reinst Reinst;
  7. typedef struct Reprog Reprog;
  8. /*
  9. * Sub expression matches
  10. */
  11. struct Resub{
  12. union
  13. {
  14. char *sp;
  15. Rune *rsp;
  16. }s;
  17. union
  18. {
  19. char *ep;
  20. Rune *rep;
  21. }e;
  22. };
  23. /*
  24. * character class, each pair of rune's defines a range
  25. */
  26. struct Reclass{
  27. Rune *end;
  28. Rune spans[64];
  29. };
  30. /*
  31. * Machine instructions
  32. */
  33. struct Reinst{
  34. int type;
  35. union {
  36. Reclass *cp; /* class pointer */
  37. Rune r; /* character */
  38. int subid; /* sub-expression id for RBRA and LBRA */
  39. Reinst *right; /* right child of OR */
  40. }u1;
  41. union { /* regexp relies on these two being in the same union */
  42. Reinst *left; /* left child of OR */
  43. Reinst *next; /* next instruction for CAT & LBRA */
  44. }u2;
  45. };
  46. /*
  47. * Reprogram definition
  48. */
  49. struct Reprog{
  50. Reinst *startinst; /* start pc */
  51. Reclass class[16]; /* .data */
  52. Reinst firstinst[5]; /* .text */
  53. };
  54. extern Reprog *regcomp(char*);
  55. extern Reprog *regcomplit(char*);
  56. extern Reprog *regcompnl(char*);
  57. extern void regerror(char*);
  58. extern int regexec(Reprog*, char*, Resub*, int);
  59. extern void regsub(char*, char*, int, Resub*, int);
  60. extern int rregexec(Reprog*, Rune*, Resub*, int);
  61. extern void rregsub(Rune*, Rune*, Resub*, int);
  62. #endif