[ANN] Various LPeg modules

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] Various LPeg modules

Sean Conner

  Since I just uploaded a bunch of new modules based upon LPeg, I thought I
would mentioned them all in one announcement instead of a bunch of
announcements as they're somewhat releated.

  First off, there's org.conman.parsers.ip 1.0.2, which fixes a bug related
to parsing IPv6 addresses.

  And now, the new modules:

        org.conman.parsers.ip-text

                Parses IPv4 and IPv6 addresses, but returns the address as
                text (instead of binary in network byte order as
                org.conman.parsers.ip does).

        org.conman.parsers.url.url

                Parses URLs, just like it says in the label.  

        org.conman.parsers.url.gopher

                Parses "gopher:" URLs.  These are different enough from the
                standard URL to warrant its own module.

        org.conman.parsers.url.tel

                Parses "tel:" URIs.  Addmittedly this is a niche URI type,
                but I tend to work with them a lot so they get their own
                module.

        org.conman.prsers.url.sip

                Parses "sip:" URIs.  Again, a niche URI type that I tend to
                work with a lot so I included this as well.

  The URL parsing modules can be combinded (since they're pretty much LPeg
expressions) much like:

                local gopher = require "org.conman.parsers.url.gopher"
                local sip    = require "org.conman.parsers.url.sip"
                local tel    = require "org.conman.parsers.url.tel"
                local url    = require "org.conman.parsers.url.url"

                url = gopher + sip + tel.tel + url -- [1]

                a = url:match "gopher://example.com/"
                b = url:match "sip:+1-(555)-555-1212;ext=[hidden email];user=phone"
                c = url:match "tel:+1-(555)-555-1212;ext=1234"
                d = url:match "http://www.example.com/path/to/ref?one=1&two=two&three=alpha&three=beta#fragtarget1"
                e = url:match "ftp://anon:fred%[hidden email]/public/files"
                f = url:match "mailto:[hidden email]?subject=What%27s%20up%3F"

  All are available via LuaRocks [2].

  -spc

[1] The org.conman.parsers.url.tel module returns a table and not an
        LPeg expression because most of it is reused in the
        org.conman.parsers.sip module, due that you can embed tel: URIs in a
        sip: URI.

[2] Except there is no LuaRocks for "org.conman.parsers.url".  I'm not
        sure if you can have a LuaRocks made up of *just* dependencies and
        no actual code.  I don't want to push things.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Various LPeg modules

Russell Haley


On Sat, Apr 21, 2018 at 6:21 PM, Sean Conner <[hidden email]> wrote:

  Since I just uploaded a bunch of new modules based upon LPeg, I thought I
would mentioned them all in one announcement instead of a bunch of
announcements as they're somewhat releated.

I like how you organize your rocks. I had forgotten how many nice parsers you have. 

How the hell did you actually get the conman.org domain?  

Cheers, 
Russ
 

  First off, there's org.conman.parsers.ip 1.0.2, which fixes a bug related
to parsing IPv6 addresses.

  And now, the new modules:

        org.conman.parsers.ip-text

                Parses IPv4 and IPv6 addresses, but returns the address as
                text (instead of binary in network byte order as
                org.conman.parsers.ip does).

        org.conman.parsers.url.url

                Parses URLs, just like it says in the label. 

        org.conman.parsers.url.gopher

                Parses "gopher:" URLs.  These are different enough from the
                standard URL to warrant its own module.

        org.conman.parsers.url.tel

                Parses "tel:" URIs.  Addmittedly this is a niche URI type,
                but I tend to work with them a lot so they get their own
                module.

        org.conman.prsers.url.sip

                Parses "sip:" URIs.  Again, a niche URI type that I tend to
                work with a lot so I included this as well.

  The URL parsing modules can be combinded (since they're pretty much LPeg
expressions) much like:

                local gopher = require "org.conman.parsers.url.gopher"
                local sip    = require "org.conman.parsers.url.sip"
                local tel    = require "org.conman.parsers.url.tel"
                local url    = require "org.conman.parsers.url.url"

                url = gopher + sip + tel.tel + url -- [1]

                a = url:match "gopher://example.com/"
                b = url:match "sip:+1-(555)-555-1212;ext=[hidden email];user=phone"
                c = url:match "tel:+1-(555)-555-1212;ext=1234"
                d = url:match "http://www.example.com/path/to/ref?one=1&two=two&three=alpha&three=beta#fragtarget1"
                e = url:match "ftp://anon:fred%40example.com@.../public/files"
                f = url:match "mailto:[hidden email]?subject=What%27s%20up%3F"

  All are available via LuaRocks [2].

  -spc

[1]     The org.conman.parsers.url.tel module returns a table and not an
        LPeg expression because most of it is reused in the
        org.conman.parsers.sip module, due that you can embed tel: URIs in a
        sip: URI.

[2]     Except there is no LuaRocks for "org.conman.parsers.url".  I'm not
        sure if you can have a LuaRocks made up of *just* dependencies and
        no actual code.  I don't want to push things.


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Various LPeg modules

Sean Conner
It was thus said that the Great Russell Haley once stated:

> On Sat, Apr 21, 2018 at 6:21 PM, Sean Conner <[hidden email]> wrote:
>
> >
> >   Since I just uploaded a bunch of new modules based upon LPeg, I thought I
> > would mentioned them all in one announcement instead of a bunch of
> > announcements as they're somewhat releated.
> >
>
> I like how you organize your rocks. I had forgotten how many nice parsers
> you have.

  Thank you. [1]

> How the hell did you actually get the conman.org domain?

  I registered it back on October 16th, 1998 because

        1) I received a "cease-and-desist" letter from a law firm claiming I
           was infringing upon a trademark I had no idea was even trade
           marked on a webpage I created;

        2) the owner of said website said I should get my own domain so *he*
           didn't have to deal with trademark issue;

        3) CONNER.COM was already taken by some odd-ball company making some
           form of computer storage device and wouldn't give it up;

        4) SPC.COM was also taken by some odd-ball magazine [2] that
           wouldn't give it up;

        5) CONMAN.ORG was available.  CONMAN because among a small set of
           friends, my nickname was "Conman" [3].

  So that's how I obtained conman.org.

  -spc (So, I got there early, but not early enough ... )

[1] For those curious, you can take a look at:

                https://github.com/spc476/LPeg-Parsers

        And they're all available via LuaRocks.

[2] Time Magazine.  No, really.

[3] Because my last name was 'Conner' and said set of friends were too
        lazy to call me by my first name, Sean, nor by Connerman, being
        three rather silly sylables.

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Various LPeg modules

Hisham
In reply to this post by Sean Conner
On 21 April 2018 at 22:21, Sean Conner <[hidden email]> wrote:
>   All are available via LuaRocks [2].

> [2]     Except there is no LuaRocks for "org.conman.parsers.url".  I'm not
>         sure if you can have a LuaRocks made up of *just* dependencies and
>         no actual code.  I don't want to push things.

In the current version, you should be able to create a rockspec of
type "builtin" with an empty modules table with no problems. The only
issue in the current release is that you'll need to give it a dummy
URL. This works:

---------------
package = "no_modules"
version = "1.0-1"
source = {
   -- any valid URL
   url = "http://example.com",
   -- fool luarocks into thinking the URL is valid
   file = "hello.lua",
}
build = {
   type = "builtin",
   modules = {},
}
---------------

In a future LuaRocks release we'll make the source.url field optional
when sensible to do so.

-- Hisham