[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: yet another pattern-matching library for Lua
- From: roberto@... (Roberto Ierusalimschy)
- Date: Wed, 3 Jan 2007 15:33:23 -0200
> 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