[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- 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 <pygy79@gmail.com>:
>
> > This has to be refined.
>
> The current version, incorporating all those points, is available at
>
> https://github.com/dlaurie/lua-notes
>
> Download lua-brief.html, don't open it, it opens as HTML source.
And I have a few examples of LPeg use here:
https://github.com/spc476/LPeg-Parsers
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
network-byte order).
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.
-spc