diff options
author | Alexey Romanoff <ar@logiceditor.com> | 2021-08-15 15:17:28 +0300 |
---|---|---|
committer | Alexey Romanoff <ar@logiceditor.com> | 2021-08-16 16:35:07 +0300 |
commit | 7668d9076da6e2ae9e220eafb5c6ee1e933c088d (patch) | |
tree | c2d8e3bdd0d6d189572bd50d8d9a078097fcc3b5 /lptypes.h | |
parent | 635a51b5c88e958c27b26e049c639ea774946367 (diff) | |
download | lpeglabel-7668d9076da6e2ae9e220eafb5c6ee1e933c088d.tar.gz lpeglabel-7668d9076da6e2ae9e220eafb5c6ee1e933c088d.tar.bz2 lpeglabel-7668d9076da6e2ae9e220eafb5c6ee1e933c088d.zip |
change prefix of source files from 'lp' to 'lpl'
To eliminate conflicts with the original LPeg:
> $ lua -e "require 'lpeg'; require 'lpeglabel'; for _ in (require'lxsh').lexers.lua.gmatch('1') do end"
lua: lpvm.c:347: match: Assertion `stack > getstackbase(L, ptop) && (stack - 1)->s != NULL' failed.
Aborted
Diffstat (limited to 'lptypes.h')
-rw-r--r-- | lptypes.h | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/lptypes.h b/lptypes.h deleted file mode 100644 index 6a6e159..0000000 --- a/lptypes.h +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | /* | ||
2 | ** $Id: lptypes.h $ | ||
3 | ** LPeg - PEG pattern matching for Lua | ||
4 | ** Copyright 2007-2019, Lua.org & PUC-Rio (see 'lpeg.html' for license) | ||
5 | ** written by Roberto Ierusalimschy | ||
6 | */ | ||
7 | |||
8 | #if !defined(lptypes_h) | ||
9 | #define lptypes_h | ||
10 | |||
11 | |||
12 | #include <assert.h> | ||
13 | #include <limits.h> | ||
14 | |||
15 | #include "lua.h" | ||
16 | |||
17 | |||
18 | #define VERSION "1.6.0" | ||
19 | |||
20 | |||
21 | #define PATTERN_T "lpeglabel-pattern" | ||
22 | #define MAXSTACKIDX "lpeglabel-maxstack" | ||
23 | |||
24 | |||
25 | /* | ||
26 | ** compatibility with Lua 5.1 | ||
27 | */ | ||
28 | #if (LUA_VERSION_NUM == 501) | ||
29 | |||
30 | #define lp_equal lua_equal | ||
31 | |||
32 | #define lua_getuservalue lua_getfenv | ||
33 | #define lua_setuservalue lua_setfenv | ||
34 | |||
35 | #define lua_rawlen lua_objlen | ||
36 | |||
37 | #define luaL_setfuncs(L,f,n) luaL_register(L,NULL,f) | ||
38 | #define luaL_newlib(L,f) luaL_register(L,"lpeglabel",f) | ||
39 | |||
40 | typedef size_t lua_Unsigned; | ||
41 | |||
42 | #endif | ||
43 | |||
44 | |||
45 | #if !defined(lp_equal) | ||
46 | #define lp_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ) | ||
47 | #endif | ||
48 | |||
49 | |||
50 | /* default maximum size for call/backtrack stack */ | ||
51 | #if !defined(MAXBACK) | ||
52 | #define MAXBACK 400 | ||
53 | #endif | ||
54 | |||
55 | |||
56 | /* maximum number of rules in a grammar (limited by 'unsigned short') */ | ||
57 | #if !defined(MAXRULES) | ||
58 | #define MAXRULES 1000 | ||
59 | #endif | ||
60 | |||
61 | |||
62 | |||
63 | /* initial size for capture's list */ | ||
64 | #define INITCAPSIZE 32 | ||
65 | |||
66 | |||
67 | /* index, on Lua stack, for subject */ | ||
68 | #define SUBJIDX 2 | ||
69 | |||
70 | /* number of fixed arguments to 'match' (before capture arguments) */ | ||
71 | #define FIXEDARGS 3 | ||
72 | |||
73 | /* index, on Lua stack, for capture list */ | ||
74 | #define caplistidx(ptop) ((ptop) + 2) | ||
75 | |||
76 | /* index, on Lua stack, for pattern's ktable */ | ||
77 | #define ktableidx(ptop) ((ptop) + 3) | ||
78 | |||
79 | /* index, on Lua stack, for backtracking stack */ | ||
80 | #define stackidx(ptop) ((ptop) + 4) | ||
81 | |||
82 | |||
83 | |||
84 | typedef unsigned char byte; | ||
85 | |||
86 | |||
87 | #define BITSPERCHAR 8 | ||
88 | |||
89 | #define CHARSETSIZE ((UCHAR_MAX/BITSPERCHAR) + 1) | ||
90 | |||
91 | |||
92 | |||
93 | typedef struct Charset { | ||
94 | byte cs[CHARSETSIZE]; | ||
95 | } Charset; | ||
96 | |||
97 | |||
98 | |||
99 | #define loopset(v,b) { int v; for (v = 0; v < CHARSETSIZE; v++) {b;} } | ||
100 | |||
101 | /* access to charset */ | ||
102 | #define treebuffer(t) ((byte *)((t) + 1)) | ||
103 | |||
104 | /* number of slots needed for 'n' bytes */ | ||
105 | #define bytes2slots(n) (((n) - 1) / sizeof(TTree) + 1) | ||
106 | |||
107 | /* set 'b' bit in charset 'cs' */ | ||
108 | #define setchar(cs,b) ((cs)[(b) >> 3] |= (1 << ((b) & 7))) | ||
109 | |||
110 | |||
111 | /* | ||
112 | ** in capture instructions, 'kind' of capture and its offset are | ||
113 | ** packed in field 'aux', 4 bits for each | ||
114 | */ | ||
115 | #define getkind(op) ((op)->i.aux & 0xF) | ||
116 | #define getoff(op) (((op)->i.aux >> 4) & 0xF) | ||
117 | #define joinkindoff(k,o) ((k) | ((o) << 4)) | ||
118 | |||
119 | #define MAXOFF 0xF | ||
120 | #define MAXAUX 0xFF | ||
121 | |||
122 | |||
123 | /* maximum number of bytes to look behind */ | ||
124 | #define MAXBEHIND MAXAUX | ||
125 | |||
126 | |||
127 | /* maximum size (in elements) for a pattern */ | ||
128 | #define MAXPATTSIZE (SHRT_MAX - 10) | ||
129 | |||
130 | |||
131 | /* size (in elements) for an instruction plus extra l bytes */ | ||
132 | #define instsize(l) (((l) + sizeof(Instruction) - 1)/sizeof(Instruction) + 1) | ||
133 | |||
134 | |||
135 | /* size (in elements) for a ISet instruction */ | ||
136 | #define CHARSETINSTSIZE instsize(CHARSETSIZE) | ||
137 | |||
138 | /* size (in elements) for a IFunc instruction */ | ||
139 | #define funcinstsize(p) ((p)->i.aux + 2) | ||
140 | |||
141 | |||
142 | |||
143 | #define testchar(st,c) (((int)(st)[((c) >> 3)] & (1 << ((c) & 7)))) | ||
144 | |||
145 | /* labeled failure begin */ | ||
146 | #define LFAIL 0 | ||
147 | |||
148 | /* update the farthest failure */ | ||
149 | #define updatefarthest(s1,s2) { if ((s2) > (s1)) s1 = s2; } | ||
150 | |||
151 | #define OUTPRED 0 | ||
152 | |||
153 | #define INPRED 1 | ||
154 | /* labeled failure end */ | ||
155 | |||
156 | #endif | ||
157 | |||