bootpeg – the bootstrapping PEG parser

Documentation Status Available on PyPI

bootpeg is a PEG parser for creating parsers from grammars – including itself. By default, it supports a modified EBNF with actions akin to PEP 617.

>>> # recreate the bootpeg parser from itself
>>> from bootpeg import import_parser, actions
>>> from bootpeg.grammars import bpeg
>>> parse_bpeg = bpeg.parse
>>> for _ in range(5):
...     parse_bpeg = import_parser(
...         bpeg.__name__, dialect=parse_bpeg, actions=actions
...     )
>>> print(bpeg.unparse(parse_bpeg))

Unlike most other Python PEG parsers, bootpeg is built for one job and one job only: Define how to transform input into a runtime representation. There is no fancy operator overloading, no custom AST formats, no clever PEG extensions, no whitespace special casing, no nothing.

bootpeg supports left-recursive PEG parsing with actions. That’s it.

Indices and tables