diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-04-22 14:25:14 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-04-22 14:25:14 -0300 |
commit | 9dac0b6d8d22705f27b139923948ab050c12f6f5 (patch) | |
tree | 13f95fe70373fc9213bb76a4a77bef221a2d80a3 | |
parent | 24bf757183d8bd97f6f5b43d916814f3269c8347 (diff) | |
download | lpeg-9dac0b6d8d22705f27b139923948ab050c12f6f5.tar.gz lpeg-9dac0b6d8d22705f27b139923948ab050c12f6f5.tar.bz2 lpeg-9dac0b6d8d22705f27b139923948ab050c12f6f5.zip |
'lpeg.version' changed to a string
-rw-r--r-- | lpeg.html | 10 | ||||
-rw-r--r-- | lptree.c | 10 | ||||
-rw-r--r-- | lptypes.h | 2 | ||||
-rwxr-xr-x | test.lua | 3 |
4 files changed, 11 insertions, 14 deletions
@@ -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. | |||
145 | LPeg also offers the <a href="re.html"><code>re</code> module</a>, | 145 | LPeg also offers the <a href="re.html"><code>re</code> module</a>, |
146 | which implements patterns following a regular-expression style | 146 | which 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, |
149 | and of course it uses LPeg to parse regular expressions and | 149 | and of course it uses LPeg to parse regular expressions and |
150 | translate them to regular LPeg patterns.) | 150 | translate 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> |
168 | An optional numeric argument <code>init</code> makes the match | 168 | An optional numeric argument <code>init</code> makes the match |
169 | start at that position in the subject string. | 169 | start at that position in the subject string. |
170 | As usual in Lua libraries, | 170 | As in the Lua standard libraries, |
171 | a negative value counts from the end. | 171 | a negative value counts from the end. |
172 | </p> | 172 | </p> |
173 | 173 | ||
@@ -191,9 +191,9 @@ returns the string <code>"pattern"</code>. | |||
191 | Otherwise returns nil. | 191 | Otherwise 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> |
196 | Returns a string with the running version of LPeg. | 196 | A 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> |
@@ -1247,12 +1247,6 @@ static int lp_setmax (lua_State *L) { | |||
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | 1249 | ||
1250 | static int lp_version (lua_State *L) { | ||
1251 | lua_pushstring(L, VERSION); | ||
1252 | return 1; | ||
1253 | } | ||
1254 | |||
1255 | |||
1256 | static int lp_type (lua_State *L) { | 1250 | static 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 | ||
@@ -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" |
@@ -48,7 +48,8 @@ end | |||
48 | 48 | ||
49 | print"General tests for LPeg library" | 49 | print"General tests for LPeg library" |
50 | 50 | ||
51 | print("version " .. m.version()) | 51 | assert(type(m.version) == "string") |
52 | print(m.version) | ||
52 | assert(m.type("alo") ~= "pattern") | 53 | assert(m.type("alo") ~= "pattern") |
53 | assert(m.type(io.input) ~= "pattern") | 54 | assert(m.type(io.input) ~= "pattern") |
54 | assert(m.type(m.P"alo") == "pattern") | 55 | assert(m.type(m.P"alo") == "pattern") |