lua-users home
lua-l archive

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


On Aug 19, 2018, at 4:32 PM, Александр Машин<alex.mashin@gmail.com> wrote:

Deal all,

as far as I understand the documentation on fold captures in LPEG
(http://www.inf.puc-rio.br/~roberto/lpeg/#cap-f), the folding function should
be called if there is at least one capture in the pattern passed to lpeg.Cf ().

However, the real minimum seems to be two.

-- Alexander Masin

Folding take minimum of 2 arguments, maybe more.
However, you can supplied defaults using lpeg.Cc

Your code need 3 + 2k arguments to trigger folding.
Since op is guaranteed a "+" or "-", the last elseif is dead code.

In other words, the code will never reach special case.