[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: lpeg.Cb bug (?) with repeated evaluation of group capture pattern
- From: Patrick Donnelly <batrick@...>
- Date: Tue, 13 Sep 2016 19:35:06 -0400
This is maybe relating to Sean Conner's recent post "Proposal for new
LPeg function: lpeg.Ctab()".
I found that for some reason LPeg is evaluating a pattern in a group
capture multiple times:
local patt = lpeg.Cg(lpeg.Ct"", "foo") * lpeg.Cb "foo" * lpeg.Cb "foo";
print(patt:match "") --> table: 0x1634280 table: 0x16342c0
(two unique tables!) Or:
local patt = lpeg.P {
lpeg.Cg(lpeg.V "v", "foo") * lpeg.Cb "foo" * lpeg.Cb "foo";
v = lpeg.Ct "" / function(...) print(...) return ... end,
}
print(patt:match "") --> table: 0x233d4a0 \n table: 0x22f0ab0 \n
table: 0x233d4a0 table: 0x22f0ab0
Whereas:
local patt = lpeg.Cg(lpeg.Cmt("", function(s,p) return p, {} end),
"foo") * lpeg.Cb "foo" * lpeg.Cb "foo";
print(patt:match "") --> table: 0x87a950 table: 0x87a950
(one table!)
Is this a bug?
--
Patrick Donnelly