[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: yet another pattern-matching library for Lua
- From: "Duncan Cross" <duncan.cross@...>
- Date: Sun, 31 Dec 2006 15:51:59 +0000
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)) )
false
>print( lpeg.match("wha&t", (BadName) * lpeg.P(-1)) )
6
>print( lpeg.match("wha&t", (GoodName + BadName) * lpeg.P(-1)) )
false
...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 <roberto@inf.puc-rio.br> wrote:
I am releasing a prototype of (yet) another pattern-matching
library for Lua, called LPeg:
http://www.inf.puc-rio.br/~roberto/lpeg.html
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
expressions.)
Have fun!
-- Roberto