LPeg - A pattern-matching library

LPeg for Defold

LPeg is a pattern-matching library by Roberto Ierusalimschy for Lua.

This extension includes source code of LPeg 1.0.2 (MIT Licence).

Installation

Add the link to the latest release zip-archive as a library dependency in the Defold project configuration.

https://github.com/astrochili/defold-lpeg/archive/master.zip

Usage

All operations are accessible through the global variable lpeg.

local P = lpeg.P 

local pattern = P'a' * P'b' ^ 0
local result = lpeg.match(pattern, 'abbc')

print(result) --> 4

Examples

This library is used by Narrator to parse the Ink language. You can check how its parser works here.

Also you can check this tutorial.

12 Likes