[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LPEG for dummies
- From: Sean Conner <sean@...>
- Date: Wed, 1 May 2013 12:00:41 -0400
It was thus said that the Great Dirk Laurie once stated:
> 2013/5/1 Pierre-Yves Gérardy <email@example.com>:
> > This has to be refined.
> The current version, incorporating all those points, is available at
> Download lua-brief.html, don't open it, it opens as HTML source.
And I have a few examples of LPeg use here:
Start with ip.lua, specifically IPv4. It's probably the easiest
production to start with (it matches an IPv4 address, and returns it as a
four-byte network address in network byte order). The IPv6 production looks
intimidating, but it's really quite straightforward, if a bit of a
brute-force parsing of IPv6 addresses (it returns a 16-byte address in
Both email.lua and json.lua use the re module extensively. I find re to
be a bit more readable than raw LPeg but that's me.