lua-users home
lua-l archive

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


It was thus said that the Great Sean Conner once stated:
> It was thus said that the Great Dirk Laurie once stated:
> > 2017-07-03 21:35 GMT+02:00 Soni L. <fakedme@gmail.com>:
> > 
> > > That was a feature request. And that trick doesn't work for captures
> > > beyond 1 without introducing nils or a massive performance hit.
> > 
> > Would the requested feature make `pat/-2` drop the second capture
> > or the first two captures?
> 
>   While I'm sympathetic to the proposal, I don't think it can be done
> without a drastic redesign of LPeg at the lowest level.  For example:

  Um ... actually, I retract what I said.  The required functionality is
quite easy to get:

	a = lpeg.C"a"
	b = lpeg.C"b"
	c = (a * b * a) / function(a,b,c) return b end   -- [ patt / -2 ]
	d = (a * b * a) / function(a,b,c) return b,c end -- [ patt / -1 ]
	e = (a * b * a) / function(a,b,c) return c end   -- [ (patt / -1) / -1 ]

  -spc (Mixed this up with an earlier request --- sorry about that)