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 Patrick Donnelly once stated:
> 
> What's wrong with using a back capture for the table and then using a
> function capture? Something like:
> 
> patt = lpeg.P {
>     foo = lpeg.Cg(lpeg.Ct "", "tab") * V "bar";
>     bar = (lpeg.Cb("tab") * V "stuff") / function (t, ...) end;
> }
> 
> Best part is that you can have nested matches of foo and the most
> "complete outermost capture" [1] of "tab" is used in bar. I use this
> to great effect in my lua formatter [2].

  I've never had luck with back captures as I can't seem to grok what
exactly they are or how they work.

  -spc