MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / pattbehind

Function pattbehind

other_src/lua/src/lpeg.cpp:1432–1456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1430
1431
1432static int pattbehind (lua_State *L) {
1433 int l1;
1434 CharsetTag st1;
1435 Instruction *p1 = getpatt(L, 1, &l1);
1436 int n = luaL_optint(L, 2, 1);
1437 luaL_argcheck(L, n <= MAXAUX, 2, "lookbehind delta too large");
1438 if (!nocalls(p1))
1439 luaL_error(L, "lookbehind pattern cannot contain non terminals");
1440 if (isfail(p1) || issucc(p1))
1441 lua_pushvalue(L, 1); /* <fail == fail; <true == true */
1442 else if (n == 1 && tocharset(p1, &st1) == ISCHARSET) {
1443 Instruction *p = newpatt(L, 1 + l1);
1444 setinstaux(p, IBack, 0, 1); p++;
1445 copypatt(p, p1, l1);
1446 }
1447 else { /* Choice L1; Back; p1; BackCommit L2; L1: fail; L2: */
1448 Instruction *p = newpatt(L, 2 + l1 + 2);
1449 setinst(p++, IChoice, 2 + l1 + 1);
1450 setinstaux(p++, IBack, 0, n);
1451 p += addpatt(L, p, 1);
1452 setinst(p++, IBackCommit, 2);
1453 setinst(p, IFail, 0);
1454 }
1455 return 1;
1456}
1457
1458
1459

Callers

nothing calls this directly

Calls 8

getpattFunction · 0.85
nocallsFunction · 0.85
tocharsetFunction · 0.85
newpattFunction · 0.85
setinstauxFunction · 0.85
addpattFunction · 0.85
luaL_errorFunction · 0.70
lua_pushvalueFunction · 0.70

Tested by

no test coverage detected