Parsing Expression Grammars (PEGs) are a way of specifying formal languages for text processing. They can be used either for matching (like regular expressions) or for building recursive descent parsers (like lex/yacc). Guile uses a superset of PEG syntax that allows more control over what information is preserved during parsing.
Wikipedia has a clear and concise introduction to PEGs if you want to familiarize yourself with the syntax: http://en.wikipedia.org/wiki/Parsing_expression_grammar.
(ice-9 peg) module works by compiling PEGs down to lambda
expressions. These can either be stored in variables at compile-time by
the define macros (
define-peg-string-patterns) or calculated explicitly at runtime
with the compile functions (
They can then be used for either parsing (
match-pattern) or searching
search-for-pattern). For convenience,
also takes pattern literals in case you want to inline a simple search
(people often use regular expressions this way).
The rest of this documentation consists of a syntax reference, an API reference, and a tutorial.
|• PEG Syntax Reference:|
|• PEG API Reference:|
|• PEG Tutorial:|
|• PEG Internals:|