aboutsummaryrefslogtreecommitdiff
path: root/lptree.c
diff options
context:
space:
mode:
authorSérgio Queiroz <sqmedeiros@gmail.com>2017-12-18 15:39:00 -0300
committerSérgio Queiroz <sqmedeiros@gmail.com>2017-12-18 15:39:00 -0300
commitc6b98103f0ab2c4afb7216e73f2eacac58cbf952 (patch)
treea98bef21fff8702c66deac2315a6a10d7d1c26df /lptree.c
parent4bdf8d40a9ca5f00e454a38d301a3ab35c9b50d5 (diff)
downloadlpeglabel-c6b98103f0ab2c4afb7216e73f2eacac58cbf952.tar.gz
lpeglabel-c6b98103f0ab2c4afb7216e73f2eacac58cbf952.tar.bz2
lpeglabel-c6b98103f0ab2c4afb7216e73f2eacac58cbf952.zip
Updating code to use the new syntax/semantics of labels
Diffstat (limited to 'lptree.c')
-rw-r--r--lptree.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lptree.c b/lptree.c
index 6d6b399..ba091d6 100644
--- a/lptree.c
+++ b/lptree.c
@@ -1204,8 +1204,16 @@ static int lp_match (lua_State *L) {
1204 r = match(L, s, s + i, s + l, code, capture, ptop, &labelf, &sfail); /* labeled failure */ 1204 r = match(L, s, s + i, s + l, code, capture, ptop, &labelf, &sfail); /* labeled failure */
1205 if (r == NULL) { /* labeled failure begin */ 1205 if (r == NULL) { /* labeled failure begin */
1206 lua_pushnil(L); 1206 lua_pushnil(L);
1207 if (labelf) 1207 if (labelf) {
1208 int isnum;
1209 lua_Integer lInt;
1208 lua_rawgeti(L, ktableidx(ptop), labelf); 1210 lua_rawgeti(L, ktableidx(ptop), labelf);
1211 lInt = lua_tointegerx(L, -1, &isnum);
1212 if (isnum) {
1213 lua_pop(L, 1);
1214 lua_pushinteger(L, lInt);
1215 }
1216 }
1209 else 1217 else
1210 lua_pushstring(L, "fail"); 1218 lua_pushstring(L, "fail");
1211 lua_pushinteger(L, sfail - (s + i) + 1); /* subject position related to the error */ 1219 lua_pushinteger(L, sfail - (s + i) + 1); /* subject position related to the error */