bootpeg – the bootstrapping PEG parser¶
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 bootpeg.grammars import bpeg
>>> bpeg.parse(
... bpeg.grammar_path.read_text()
... )
Unlike most other Python PEG parsers which are top-down Packrat parsers, bootpeg provides a bottom-up Pika parser: it handles left-recursive grammars natively, allows recovering partial parse results, and runs in linear time for usual inputs. This makes it straightforward to define custom grammars without worrying about their implementation.