diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-02-20 10:13:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-02-20 10:13:46 -0300 |
commit | e08e5df853560de6482d84066a7accc6a18de545 (patch) | |
tree | ee19686bb35da90709a32ed24bf7855de1a3946a /lpcap.h | |
download | lpeg-e08e5df853560de6482d84066a7accc6a18de545.tar.gz lpeg-e08e5df853560de6482d84066a7accc6a18de545.tar.bz2 lpeg-e08e5df853560de6482d84066a7accc6a18de545.zip |
Fist version of LPeg on GIT
LPeg repository is being moved to git. Past versions won't be moved;
they are still available in RCS.
Diffstat (limited to 'lpcap.h')
-rw-r--r-- | lpcap.h | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ | |||
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 | |||