27th Brazilian Symposium on Programming Languages
Tutorial - An Introduction to LPeg
PEG (Parsing Expression Grammar) is a formalism for describing languages that ranges from problems typically handled by regular expressions (e.g., searching for a date in a text) to the complete description of programming languages.
LPeg is a PEG-based pattern matching library for Lua. In addition to the language description constructions coming from PEG, LPeg also offers a powerful capture scheme for data processing, which allows everything from simple captures of a pattern in a text to the construction of abstract program syntax trees.
In this tutorial we will present LPeg in a very practical way, starting from its use for simple tasks and evolving in the complexity of the patterns. (No prior knowledge of Lua is necessary)