[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPEG -- getting clobbered by pattern too big!
- From: Norman Ramsey <nr@...>
- Date: Sat, 29 Nov 2008 18:15:11 -0500
> 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 = ...
to
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...
Norman