diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-06-15 11:28:33 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-06-15 11:28:33 -0300 |
commit | a561630f17e61548193666abf9a8b20f20462558 (patch) | |
tree | b1ffda7472f2c801bb7677239b42b0e09b1ceec9 /lpcap.h | |
parent | cf1705c1d96b549ef5887a2bc3038dbc31912e50 (diff) | |
download | lpeg-a561630f17e61548193666abf9a8b20f20462558.tar.gz lpeg-a561630f17e61548193666abf9a8b20f20462558.tar.bz2 lpeg-a561630f17e61548193666abf9a8b20f20462558.zip |
Full captures can contain nested captures
Nested captures can be recognized because they start (and end) inside
the character range of the full capture. This optimization can remove
a lot of 'close' captures from the capture logs.
Diffstat (limited to 'lpcap.h')
-rw-r--r-- | lpcap.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -59,6 +59,18 @@ typedef struct CapState { | |||
59 | } CapState; | 59 | } CapState; |
60 | 60 | ||
61 | 61 | ||
62 | #define captype(cap) ((cap)->kind) | ||
63 | |||
64 | #define isclosecap(cap) (captype(cap) == Cclose) | ||
65 | #define isopencap(cap) ((cap)->siz == 0) | ||
66 | |||
67 | /* true if c2 is (any number of levels) inside c1 */ | ||
68 | #define capinside(c1,c2) \ | ||
69 | (isopencap(c1) ? !isclosecap(c2) \ | ||
70 | : (c2)->index < (c1)->index + (c1)->siz - 1) | ||
71 | |||
72 | |||
73 | |||
62 | int runtimecap (CapState *cs, Capture *close, const char *s, int *rem); | 74 | int runtimecap (CapState *cs, Capture *close, const char *s, int *rem); |
63 | int getcaptures (lua_State *L, const char *s, const char *r, int ptop); | 75 | int getcaptures (lua_State *L, const char *s, const char *r, int ptop); |
64 | int finddyncap (Capture *cap, Capture *last); | 76 | int finddyncap (Capture *cap, Capture *last); |