lua-users home
lua-l archive

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


Recently I've hit the LPeg max-pattern-size limit while working on a
parser, so I've been trying to cut down the size of the resulting
compiled pattern.

My original pattern consisted of a lot of definitions of various lexical
elements and simple constructs in local variables, and a true LPeg
grammar definition using P{..}, only for describing the recursive part
of the parser.

While trying to optimize I have been moving the separate locals inside
the grammar, which seem to have shrunk the total size of the parser to
only 30% of it's original size. Quite an optimization!

So, can anybody explain what is happening here, why the big difference
in resulting pattern size ? Is LPeg doing some kind of optimization,
only possible inside a grammar definition ? Is it considered best
practice to put as much as possible inside the grammar definition to
allow better optimization ?