SPELL=lpeg VERSION=1.0.1 SOURCE=$SPELL-$VERSION.tar.gz SOURCE_URL[0]=http://www.inf.puc-rio.br/~roberto/$SPELL/$SOURCE SOURCE_HASH=sha512:7b43fbee7eff443000986684bc56bba6d2796a31cf860740746c70e155bdea1b62a46b93f97e2747e3ef0f63e965148778ac2985d0f2d83e1e37ec4ebbabf4aa SOURCE_DIRECTORY="$BUILD_DIRECTORY/$SPELL-$VERSION" WEB_SITE=http://www.inf.puc-rio.br/~roberto/lpeg.html LICENSE[0]=MIT ENTERED=20080823 SHORT="Parsing Expression Grammars for Lua" cat << EOF LPeg is a new pattern-matching library for Lua, based on Parsing Expression Grammars (PEGs). In this text, I assume you are familiar with PEGs. If you are not, you can get a quick start reading the Wikipedia Entry for PEGs or Section 2 of Parsing Expression Grammars: A Recognition-Based Syntactic Foundation (the section has only one page). The nice thing about PEGs is that it has a formal basis (instead of being an ad-hoc set of features), allows an efficient and simple implementation, and does most things we expect from a pattern-matching library (and more, as we can define entire grammars). Following the Snobol tradition, LPeg defines patterns as first-class objects. That is, patterns are regular Lua values (represented by userdata). The library offers several functions to create and compose patterns. With the use of metamethods, several of these functions are provided as infix or prefix operators. On the one hand, the result is usually much more verbose than the typical encoding of patterns using the so called regular expressions (which typically are not regular expressions in the formal sense). On the other hand, first-class patterns allow much better documentation (as it is easy to comment the code, to use auxiliary variables to break complex definitions, etc.) and are extensible, as we can define new functions to create and compose patterns. EOF