lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> [...]
> That would seem to indicate that the #lpeg.P(1) is not failing at the
> end of the input.
> 
> If I replace #lpeg.P(1) with lpeg.P(1) it works, though since it consumes
> a character it makes writing the reported error position off by one.
> 
> Any ideas?

This is a bug. It will be fixed in the next version. You may fix it
removing a wrong optimization in function 'pattand_l' (lpeg.c:1285):

  if (isfail(p1) || issucc(p1))
    lua_pushvalue(L, 1);  /* &fail == fail; &true == true */
- else if (tocharset(p1, &st1) == ISCHARSET) {
-   Instruction *p = newpatt(L, CHARSETINSTSIZE + 1);
-   setinst(p, ISet, CHARSETINSTSIZE + 1);
-   loopset(i, p[1].buff[i] = ~st1.cs[i]);
-   setinst(p + CHARSETINSTSIZE, IFail, 0);
- }
  else {
    Instruction *p = newpatt(L, 1 + l1 + 2);
    setinst(p++, IChoice, 1 + l1 + 1);


-- Roberto