aboutsummaryrefslogtreecommitdiff
path: root/lpcap.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-02-20 10:13:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-02-20 10:13:46 -0300
commite08e5df853560de6482d84066a7accc6a18de545 (patch)
treeee19686bb35da90709a32ed24bf7855de1a3946a /lpcap.h
downloadlpeg-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.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/lpcap.h b/lpcap.h
new file mode 100644
index 0000000..6133df2
--- /dev/null
+++ b/lpcap.h
@@ -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 */
13typedef 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
32typedef 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
40typedef 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
50int runtimecap (CapState *cs, Capture *close, const char *s, int *rem);
51int getcaptures (lua_State *L, const char *s, const char *r, int ptop);
52int finddyncap (Capture *cap, Capture *last);
53
54#endif
55
56