lua-users home
lua-l archive

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


> I've tried the Lua parser on some real code.
> Testing on files in src/luacheck/ in
> https://github.com/mpeterv/luacheck at commit ca21257:
>
> analyze.lua, linearize.lua, parser.lua: errors with `too many
> captures` in lpeglabel.match call.
> format.lua: it seems to be confused by `{[[...]]}` construction.
>
>     Syntax error #1: expected an _expression_ after '[' for the table
> key at line 332(col 18)
>     Syntax error #2: expected '=' after the table key at line 332(col 58)
>     Syntax error #3: expected an _expression_ after '=' at line 333(col 4)
>     Syntax error #4: expected '}' to close the table constructor at
> line 333(col 4)
>
> Testing on files from Luarocks show some other types of errors. But
> these can be fixed.
> The `too many captures` error is more troubling as it appears for most
> larger files.
> Additionally, the memory consumption of the parser seemed very high on
> these larger files
> (hint: turn off swap before testing this if you have it enabled normally).
> Not sure if this is due to limitations of parser-gen or lpeglabel or
> perhaps some bad case in grammar.

For reference, https://github.com/andremm/lua-parser does not have any issues
with any of these files.

-- Best regards,
-- Peter Melnichenko
Thank you for testing it Peter. I have updated the code and fixed all the issues you reported. The recovery pattern in Lua parser caused an infinite loop - the memory usage should be much more stable now. The memory usage will still be a little bit higher, as the automatic AST building captures even unnecessary tokens, i.e. "then", "end", etc. The parser in your link should thus have a lower memory usage, but not by much I assume.
Also, I tested parsing all the luacheck files - it works fine now.

Ben