lua-users home
lua-l archive

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


> [So basically I could just define my suggested "lpeg.flush" like:
> 
>  function lpeg_flush (pattern)
>    return lpeg.Cmt (pattern, function () return true end)
>  end

Yes. (This "flush" flushes all captures and throws away any occasional
results.)


> Are you saying I can just do:
> 
> FILE =
>    (lpeg.P"begin"
>     * lpeg.Cmt(SUPER_COMPLEX_GRAMMAR_WITH_LOTS_OF_CAPTURES,
>                function () return true end)^0
>     * lpeg.P"end")
> 
> ?

Yes.


> Will the use of Cmt here affect the speed of
> SUPER_COMPLEX_GRAMMAR_WITH_LOTS_OF_CAPTURES?

Only real measure can answer that question, but a match-time capture is
only a little more expensive than a function capture (the kind you are
already using to create your side effects).

-- Roberto