[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Weird re.lua compile() call syntax.
- From: Choonster TheMage <choonster.2010@...>
- Date: Sat, 23 Nov 2013 02:23:58 +1100
On 23 November 2013 02:08, Georgios Petsagourakis <firstname.lastname@example.org> wrote:
> Hello lua-l,
> I was studying the orbit source and I am having a hard time the lines found
> Could anyone help me out understanding this?
The first part of line 22 is calling the `re.compile` function with a
single string argument (parentheses are optional when you call a
function with a single string/table literal as its only argument),
which compiles a regular expression into a standard LPeg pattern. It
then uses LPeg's overloaded `/` (division) operator to turn the
pattern returned by `re.compile` into a function capture, which
calls the function defined on lines 23-32 with the captures made by
the pattern as arguments and uses the function's return values as the
results of the capture. It then assigns this function capture to the
new local variable `param`.
I don't know enough about LPeg to tell you exactly what that function
does, but hopefully the above explanation helps.