[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Simple peg examples
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 12 Jun 2012 13:13:21 +0200
On Mon, Jun 11, 2012 at 4:32 AM, Glenn Edgar <glenn-edgar@onyxengr.com> wrote:
> I was trying to use peg module. I could not figure it out. Are there
> simple complete programs.
I have just added a tutorial to the Wiki:
http://lua-users.org/wiki/LpegTutorial
Just a first draft, and I must fully disclose that I Am Not an Expert.
Please edit at will. The example at the end is the complete program
I used to convert the Markdown of the article into Lua wiki markup.
(Due to escaping problems I was unable to mention the magic '{{{' in
code examples, so I edited it to be '[[['. The conversion program has
bugs, as well, e.g. any mention of '> ' causes the blockquote logic to
kick in)
There's also a fairly old article by Gavin Wraith
http://www.wra1th.plus.com/lua/peg/PEG.html
Although he uses RiscLua syntax: mentally substitute 'function' for
'\' and 'return' for '==>'.
And the extremely cool notation 'local P,C in lpeg' is short for the
clumsy 'local P,C = lpeg.P, lpeg.C'
steve d.