You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lpcap.h 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. ** $Id: lpcap.h $
  3. */
  4. #if !defined(lpcap_h)
  5. #define lpcap_h
  6. #include "lptypes.h"
  7. /* kinds of captures */
  8. typedef enum CapKind {
  9. Cclose, /* not used in trees */
  10. Cposition,
  11. Cconst, /* ktable[key] is Lua constant */
  12. Cbackref, /* ktable[key] is "name" of group to get capture */
  13. Carg, /* 'key' is arg's number */
  14. Csimple, /* next node is pattern */
  15. Ctable, /* next node is pattern */
  16. Cfunction, /* ktable[key] is function; next node is pattern */
  17. Cquery, /* ktable[key] is table; next node is pattern */
  18. Cstring, /* ktable[key] is string; next node is pattern */
  19. Cnum, /* numbered capture; 'key' is number of value to return */
  20. Csubst, /* substitution capture; next node is pattern */
  21. Cfold, /* ktable[key] is function; next node is pattern */
  22. Cruntime, /* not used in trees (is uses another type for tree) */
  23. Cgroup /* ktable[key] is group's "name" */
  24. } CapKind;
  25. typedef struct Capture {
  26. const char *s; /* subject position */
  27. unsigned short idx; /* extra info (group name, arg index, etc.) */
  28. byte kind; /* kind of capture */
  29. byte siz; /* size of full capture + 1 (0 = not a full capture) */
  30. } Capture;
  31. typedef struct CapState {
  32. Capture *cap; /* current capture */
  33. Capture *ocap; /* (original) capture list */
  34. lua_State *L;
  35. int ptop; /* index of last argument to 'match' */
  36. const char *s; /* original string */
  37. int valuecached; /* value stored in cache slot */
  38. int reclevel; /* recursion level */
  39. } CapState;
  40. int runtimecap (CapState *cs, Capture *close, const char *s, int *rem);
  41. int getcaptures (lua_State *L, const char *s, const char *r, int ptop);
  42. int finddyncap (Capture *cap, Capture *last);
  43. #endif