lua-users home
lua-l archive

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

 > Usually the easiest way to reduce the size of a grammar is to change some
 > pattern that is used in many places to a rule. For instance, we may
 > have defined spaces like this:
 > Sp = lpeg.Set" \t\n" + '--' * (1 - lpeg.P"\n")^0
 > Then, each use of 'Sp' will repeat the opcode for that pattern (some dozens
 > of opcodes). 

Aha!  This is exactly my problem.  I have now changed a lot of
definitions like this:

local spaces = ...


local spaces = lp.V 'spaces'
nt.spaces = ...

 > (But I will try to remove this limit in some future version. Several
 > people have problems with it...)

It should be fairly easy to hash-cons on the userdata value so that
you don't compile it twice.  But I haven't looked at the details of
your compiler since July...