lua-users home
lua-l archive

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

In message 
you wrote:

> On Mon, Jun 11, 2012 at 4:32 AM, Glenn Edgar <> wrote:
> > I was trying to use peg module.
> ...............
> There's also a fairly old article by Gavin Wraith
> Although he uses RiscLua syntax: mentally substitute 'function' for
> '\' and 'return' for '==>'.

That should be '=>'.
> And the extremely cool notation 'local P,C in lpeg' is short for the
> clumsy 'local P,C = lpeg.P, lpeg.C'

It is cool. It is not as widely applicable as Peter Shook's original
patch, being only useable after the keyword 'local'. However, it does
encourage the use of local variables and I find it very convenient.

On the topic of lpeg I am full of admiration and frustration.
I am amazed that nobody (as far as I know) used an abstract datatype 
for patterns years ago. Conflating patterns with strings has been a 
big source of unreadability and exploding escape-sequences. 
My frustration is my own fault for not practicing with lpeg enough. 
I still find it hard to write the patterns and captures that I really 
want. I also find it hard to express error-trapping smoothly with 
lpeg. But the fault is with me, not lpeg. I suspect that human
psychology is to blame; we relegate to the sidelines, and so overlook,
the outcomes that we do not want, and this explains why we often
need so many shots before we get the right bug-trapping when we
try to write down a pattern.

Gavin Wraith (
Home page: