lua-users home
lua-l archive

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


> Already there is an example for c-comment parsing (/*  */).  Also
> there is somewhat of a question of how to optimize the LPeg
> expressions, since there are multiple ways to get the same result, but
> they perform differently.

One rule of thumb is spanning a charset is usually faster than anything
else. So, your example can be made faster with the following code:

searchParser = ((1 - lpeg.P"/")^0 * (lpeg.C(FULL_COMMENT_CONTENTS) + 1))^0


-- Roberto