lua-users home
lua-l archive

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

I'm impressed, LPeg looks like a very powerful addition.

However, this seems like a bug:

>print( lpeg.match("wha&t", (GoodName) * lpeg.P(-1)) )

>print( lpeg.match("wha&t", (BadName) * lpeg.P(-1)) )

>print( lpeg.match("wha&t", (GoodName + BadName) * lpeg.P(-1)) )

...I'm fairly new to the concept of parsing grammars, so I may have
just misunderstood something, but shouldn't the third command get the
same response as the second one, regardless of what the patterns are?

On 12/27/06, Roberto Ierusalimschy <> wrote:
I am releasing a prototype of (yet) another pattern-matching
library for Lua, called LPeg:

Because the library is rather unconventional, all things in it are
experimental (even its name).

Unlike most pattern-matching libraries, LPeg is not based on regular
expressions, but on Parsing Expression Grammars (which in turn are based
on TDPLs, a technique using top-down parsers with limited backtracking
developed in the 70s):

Why LPeg?

- It seems to be quite efficient.

- It has a simple implementation; patterns are translated to programs
for a small parsing machine.

- It is quite complete. Besides the usual pattern-matching operators
based on regular expressions (alternation, concatenation, and
repetition, but with a twisted semantics), it also supports BNF-like
grammars (again with a twisted semantics; see the docs).

- It has a formal ground. (Unlike most pattern-matching libraries today,
which are ad-hoc collections of facilities loosely inspired by regular

Have fun!

-- Roberto