lua-users home
lua-l archive

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


On Tue, Sep 3, 2013 at 11:33 AM, Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Roberto Ierusalimschy once stated:
>> > I'm looking for an email parser for lua, and came across Sean Conner's work [1]
>> > Trying to run it with Lpeg 0.12 you get a failure:
>> >     bad argument #1 to '?' (grammar has too many rules)
>> >
>> > It used to work with Lpeg 0.10 [2], what new limits has Lpeg 0.12 brought along?
>>
>> LPeg 0.12 has a constant MAXRULES, which is currently defined as 200. Just
>> change that to a larger number and recompile LPeg. (And tell me how many
>> rules you need.)
>
>   I counted 212.  I set MAXRULES to 220 and it didn't complain:
>
> [spc]lucy:~/source/parse/Lua>lua email.lua
> [spc]lucy:~/source/parse/Lua>
>
>   So that's good.  But the code uses the 0.10.2 re syntax for table
> captures---I thought 0.12 supports it but I can't find exactly where it
> states that.
>
>   Maybe bump MAXRULES to 250 or 300?
>
>> (I thought 200 would be huge, but looking at your example 200 looks really
>> humble :)
>
>   You almost guess right 8-)
>
>   -spc

I'm eyeballing an 800-rule grammar that I just wrote a custom parser
for (couldn't use LPeg due to course restrictions, but my parser is
sort of PEG-ish)... maybe parsing C++ source code isn't a suitable use
case for LPeg. ;)

/s/ Adam