lua-users home
lua-l archive

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


On Tue, Mar 4, 2014 at 12:00 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> Is LPeg useful enough to justify how very much larger
> Lua's C source code will become if it is included?
>
> IMHO, if the gain will merely be that the ordinary user
> would no longer need to build/download it separately
> (which LuaRocks can do for you) and require it (which
> takes one line of code), the answer is NO.
>
> On the other hand, if the Lua implementation itself exploits
> it for its lexer/parser/VM encoder and its string library,
> thus demonstrating how useful it can be while at the same
> time providing some highly instructive well-written LPeg
> code, the answer is YES!
>

I'd also like to see LPeg make it into Lua's core, it offers so much
compared to what Lua's patterns or even PCRE can do.  That said, I
don't think it's C implementation is that friendly.  I had high hopes
when I found out about the Lua-only "lulzpeg" project but it looks
like the author tried to emulate the C implementation of LPeg in Lua.
I was hoping for something simpler and more "functional" (as in
functional programming).  Lua's pattern matching code is very concise,
but it is similarly difficult to hack on and add to (if one wanted).
I have for a long time wished Lua allowed for alternation and grouped
ranged matches ("(cat|dog){3,5}").  I did some from Perl but I don't
want all of PCRE.

Anyway, I don't like LPeg's C.  It would make sense to use it for
parsing Lua source, it just feels funny to embed the LPeg VM within
the Lua VM.  Maybe I'm superficial for running from that thought..