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