| 1430 | |
| 1431 | |
| 1432 | static 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 |
nothing calls this directly
no test coverage detected