Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 20, 2020. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathlptypes.h
More file actions
Latest commit
147 lines (85 loc) · 2.87 KB
/
Copy pathlptypes.h
File metadata and controls
147 lines (85 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
** $Id: lptypes.h,v 1.8 2013/04/12 16:26:38 roberto Exp $
** LPeg - PEG pattern matching for Lua
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
** written by Roberto Ierusalimschy
*/
#if !defined(lptypes_h)
#definelptypes_h
#if !defined(LPEG_DEBUG)
#defineNDEBUG
#endif
#include<assert.h>
#include<limits.h>
#include"lua.h"
#defineVERSION "0.12"
#definePATTERN_T "lpeg-pattern"
#defineMAXSTACKIDX "lpeg-maxstack"
/*
** compatibility with Lua 5.2
*/
#if (LUA_VERSION_NUM==502)
#undef lua_equal
#definelua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
#undef lua_getfenv
#definelua_getfenv lua_getuservalue
#undef lua_setfenv
#definelua_setfenv lua_setuservalue
#undef lua_objlen
#definelua_objlen lua_rawlen
#undef luaL_register
#defineluaL_register(L,n,f) \
{ if ((n) == NULL) luaL_setfuncs(L,f,0); else luaL_newlib(L,f); }
#endif
/* default maximum size for call/backtrack stack */
#if !defined(MAXBACK)
#defineMAXBACK 100
#endif
/* maximum number of rules in a grammar */
#defineMAXRULES 200
/* initial size for capture's list */
#defineINITCAPSIZE 32
/* index, on Lua stack, for subject */
#defineSUBJIDX 2
/* number of fixed arguments to 'match' (before capture arguments) */
#defineFIXEDARGS 3
/* index, on Lua stack, for capture list */
#definecaplistidx(ptop) ((ptop) + 2)
/* index, on Lua stack, for pattern's ktable */
#definektableidx(ptop) ((ptop) + 3)
/* index, on Lua stack, for backtracking stack */
#definestackidx(ptop) ((ptop) + 4)
typedefunsigned charbyte;
#defineBITSPERCHAR 8
#defineCHARSETSIZE ((UCHAR_MAX/BITSPERCHAR) + 1)
typedefstructCharset {
bytecs[CHARSETSIZE];
} Charset;
#defineloopset(v,b) { int v; for (v = 0; v < CHARSETSIZE; v++) {b;} }
/* access to charset */
#definetreebuffer(t) ((byte *)((t) + 1))
/* number of slots needed for 'n' bytes */
#definebytes2slots(n) (((n) - 1) / sizeof(TTree) + 1)
/* set 'b' bit in charset 'cs' */
#definesetchar(cs,b) ((cs)[(b) >> 3] |= (1 << ((b) & 7)))
/*
** in capture instructions, 'kind' of capture and its offset are
** packed in field 'aux', 4 bits for each
*/
#definegetkind(op) ((op)->i.aux & 0xF)
#definegetoff(op) (((op)->i.aux >> 4) & 0xF)
#definejoinkindoff(k,o) ((k) | ((o) << 4))
#defineMAXOFF 0xF
#defineMAXAUX 0xFF
/* maximum number of bytes to look behind */
#defineMAXBEHIND MAXAUX
/* maximum size (in elements) for a pattern */
#defineMAXPATTSIZE (SHRT_MAX - 10)
/* size (in elements) for an instruction plus extra l bytes */
#defineinstsize(l) (((l) + sizeof(Instruction) - 1)/sizeof(Instruction) + 1)
/* size (in elements) for a ISet instruction */
#defineCHARSETINSTSIZE instsize(CHARSETSIZE)
/* size (in elements) for a IFunc instruction */
#definefuncinstsize(p) ((p)->i.aux + 2)
#definetestchar(st,c) (((int)(st)[((c) >> 3)] & (1 << ((c) & 7))))
#endif