aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-04-22 14:25:14 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-04-22 14:25:14 -0300
commit9dac0b6d8d22705f27b139923948ab050c12f6f5 (patch)
tree13f95fe70373fc9213bb76a4a77bef221a2d80a3
parent24bf757183d8bd97f6f5b43d916814f3269c8347 (diff)
downloadlpeg-9dac0b6d8d22705f27b139923948ab050c12f6f5.tar.gz
lpeg-9dac0b6d8d22705f27b139923948ab050c12f6f5.tar.bz2
lpeg-9dac0b6d8d22705f27b139923948ab050c12f6f5.zip
'lpeg.version' changed to a string
-rw-r--r--lpeg.html10
-rw-r--r--lptree.c10
-rw-r--r--lptypes.h2
-rwxr-xr-xtest.lua3
4 files changed, 11 insertions, 14 deletions
diff --git a/lpeg.html b/lpeg.html
index 1295c4f..87348cf 100644
--- a/lpeg.html
+++ b/lpeg.html
@@ -22,7 +22,7 @@
22 </div> 22 </div>
23 <div id="product_name"><big><strong>LPeg</strong></big></div> 23 <div id="product_name"><big><strong>LPeg</strong></big></div>
24 <div id="product_description"> 24 <div id="product_description">
25 Parsing Expression Grammars For Lua, version 1.0 25 Parsing Expression Grammars For Lua, version 1.1
26 </div> 26 </div>
27</div> <!-- id="product" --> 27</div> <!-- id="product" -->
28 28
@@ -145,7 +145,7 @@ so, it succeeds only at the end of the subject.
145LPeg also offers the <a href="re.html"><code>re</code> module</a>, 145LPeg also offers the <a href="re.html"><code>re</code> module</a>,
146which implements patterns following a regular-expression style 146which implements patterns following a regular-expression style
147(e.g., <code>[09]+</code>). 147(e.g., <code>[09]+</code>).
148(This module is 260 lines of Lua code, 148(This module is 270 lines of Lua code,
149and of course it uses LPeg to parse regular expressions and 149and of course it uses LPeg to parse regular expressions and
150translate them to regular LPeg patterns.) 150translate them to regular LPeg patterns.)
151</p> 151</p>
@@ -167,7 +167,7 @@ or the <a href="#captures">captured values</a>
167<p> 167<p>
168An optional numeric argument <code>init</code> makes the match 168An optional numeric argument <code>init</code> makes the match
169start at that position in the subject string. 169start at that position in the subject string.
170As usual in Lua libraries, 170As in the Lua standard libraries,
171a negative value counts from the end. 171a negative value counts from the end.
172</p> 172</p>
173 173
@@ -191,9 +191,9 @@ returns the string <code>"pattern"</code>.
191Otherwise returns nil. 191Otherwise returns nil.
192</p> 192</p>
193 193
194<h3><a name="f-version"></a><code>lpeg.version ()</code></h3> 194<h3><a name="f-version"></a><code>lpeg.version</code></h3>
195<p> 195<p>
196Returns a string with the running version of LPeg. 196A string (not a function) with the running version of LPeg.
197</p> 197</p>
198 198
199<h3><a name="f-setstack"></a><code>lpeg.setmaxstack (max)</code></h3> 199<h3><a name="f-setstack"></a><code>lpeg.setmaxstack (max)</code></h3>
diff --git a/lptree.c b/lptree.c
index 62acc5c..30cef67 100644
--- a/lptree.c
+++ b/lptree.c
@@ -1247,12 +1247,6 @@ static int lp_setmax (lua_State *L) {
1247} 1247}
1248 1248
1249 1249
1250static int lp_version (lua_State *L) {
1251 lua_pushstring(L, VERSION);
1252 return 1;
1253}
1254
1255
1256static int lp_type (lua_State *L) { 1250static int lp_type (lua_State *L) {
1257 if (testpattern(L, 1)) 1251 if (testpattern(L, 1))
1258 lua_pushliteral(L, "pattern"); 1252 lua_pushliteral(L, "pattern");
@@ -1323,7 +1317,7 @@ static struct luaL_Reg pattreg[] = {
1323 {"R", lp_range}, 1317 {"R", lp_range},
1324 {"utfR", lp_utfr}, 1318 {"utfR", lp_utfr},
1325 {"locale", lp_locale}, 1319 {"locale", lp_locale},
1326 {"version", lp_version}, 1320 {"version", NULL},
1327 {"setmaxstack", lp_setmax}, 1321 {"setmaxstack", lp_setmax},
1328 {"type", lp_type}, 1322 {"type", lp_type},
1329 {NULL, NULL} 1323 {NULL, NULL}
@@ -1352,6 +1346,8 @@ int luaopen_lpeg (lua_State *L) {
1352 luaL_newlib(L, pattreg); 1346 luaL_newlib(L, pattreg);
1353 lua_pushvalue(L, -1); 1347 lua_pushvalue(L, -1);
1354 lua_setfield(L, -3, "__index"); 1348 lua_setfield(L, -3, "__index");
1349 lua_pushliteral(L, "LPeg " VERSION);
1350 lua_setfield(L, -2, "version");
1355 return 1; 1351 return 1;
1356} 1352}
1357 1353
diff --git a/lptypes.h b/lptypes.h
index eea3d0c..ccb4c18 100644
--- a/lptypes.h
+++ b/lptypes.h
@@ -15,7 +15,7 @@
15#include "lua.h" 15#include "lua.h"
16 16
17 17
18#define VERSION "1.0.2" 18#define VERSION "1.1.0"
19 19
20 20
21#define PATTERN_T "lpeg-pattern" 21#define PATTERN_T "lpeg-pattern"
diff --git a/test.lua b/test.lua
index e86c21a..403aa09 100755
--- a/test.lua
+++ b/test.lua
@@ -48,7 +48,8 @@ end
48 48
49print"General tests for LPeg library" 49print"General tests for LPeg library"
50 50
51print("version " .. m.version()) 51assert(type(m.version) == "string")
52print(m.version)
52assert(m.type("alo") ~= "pattern") 53assert(m.type("alo") ~= "pattern")
53assert(m.type(io.input) ~= "pattern") 54assert(m.type(io.input) ~= "pattern")
54assert(m.type(m.P"alo") == "pattern") 55assert(m.type(m.P"alo") == "pattern")