bootpeg – the bootstrapping PEG parser

Documentation Status Available on PyPI

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

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

Unlike most other Python PEG parsers which are top-down parsers, bootpeg provides a bottom-up Pika parser: it handles left-recursive grammars natively, allows recovering partial parse results, and is guaranteed to run in linear time. Like any PEG parser, bootpeg automatically creates unambiguous grammars, supports infinite lookahead, and allows to express grammars comfortably.

  • Native support for left-recursion and left-associativity.

  • Builtin error reporting covering multiple failures.

  • Automatic parser generation from a multitude of meta-grammars.

This makes it straightforward to implement your own custom grammars without worrying about their implementation.

Indices and tables