The Idle PEG library

This is the preliminary documentation for the Idle PEG library (PEG is short for Parsing Expression Grammar). PEGs are pattern-matching expressions on steroids: a PEG is essentially a description of a recursive descent parser for a specific language (which can be as trivial as parsing numbers), including the lexical component. PEGs can be more difficult to get to grips with than the more limited regular expressions, but since they encapsulate whole grammars in a relatively straightforward description, they help solve classes of problems that are beyond any reasonable attempt with regular expressions.

This implementation is based on Roberto Ierusalimschy's LPEG library which in turn is a full implementation of the concepts dreamt up by Bryan Ford. Roberto's library is technically still beta code, so you should not rely on any functionality being there in future versions.

The lpeg module is loaded with


After this the lpeg functions are accessible with the prefix lpeg. There are a couple of convenience functions which implement a sort of regular expression simulation; these are found in submodule

For further usage information and a description of the lpeg functions please see Roberto's description of PEGs and lpeg. The full documentation will be included here once the lpeg module is out of beta.

$$ built from IdlePEG.txt d106963c4f77 Mon Sep 27 13:27:10 2010 +0000 thomasl $$