Skip to main content

Python bindings for bison/flex parser engine

Project description

PyBison

python versions wheel Build

Welcome to PyBison!
Bringing GNU Bison/Flex's raw speed and power to Python

What is PyBison?

PyBison is a framework which effectively 'wraps' Bison and Flex into a Python class structure.

You define a parser class, define tokens and precedences as attributes, and parse targets as methods with rules in the docstrings, then instantiate and run.

Black Magick happens in the background, whereupon you get callbacks each time yyparse() resolves a parse target.

Install

Now, install pybison with:

pip install pybison

The following command will verify if the installation succeeded:

python -c "import bison"

There are already parsers for Python. Why re-invent the wheel?

I looked at all the Python-based parsing frameworks.

IMO, the best one was PLY - a pure-python lexx/yacc implementation (which I have borrowed from heavily in designing PyBison's OO model).

But PLY suffers some major limitations:

  • usage of 'named groups' regular expressions in the lexer creates a hard limit of 100 tokens - not enough to comfortably handle major languages
  • pure-python implementation is a convenience, but incurs a cruel performance penalty
  • the parser engine is SLR, not full LALR(1)

The other frameworks utilise a fiddly script syntax -

How do I use this?

Refer to the examples and the docs for usage.

Development

You will need:

We assume that Python, pip and a C compiler is already installed.

Dependencies

First, install the dependencies bison and flex.

Arch Linux

sudo pacman -S bison flex

Ubuntu

sudo apt-get install bison flex

Debugging

See the short introduction into debugging.

Collaborators

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pybison, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size pybison-0.3.1-cp35-cp35m-macosx_10_14_x86_64.whl (133.5 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size pybison-0.3.1-cp35-cp35m-manylinux1_x86_64.whl (463.2 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size pybison-0.3.1-cp35-cp35m-manylinux2010_x86_64.whl (463.2 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size pybison-0.3.1-cp35-cp35m-win_amd64.whl (249.2 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size pybison-0.3.1-cp36-cp36m-macosx_10_14_x86_64.whl (143.0 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pybison-0.3.1-cp36-cp36m-manylinux1_x86_64.whl (489.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pybison-0.3.1-cp36-cp36m-manylinux2010_x86_64.whl (489.2 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pybison-0.3.1-cp36-cp36m-win_amd64.whl (256.1 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pybison-0.3.1-cp37-cp37m-macosx_10_14_x86_64.whl (132.3 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pybison-0.3.1-cp37-cp37m-manylinux1_x86_64.whl (485.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pybison-0.3.1-cp37-cp37m-manylinux2010_x86_64.whl (485.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pybison-0.3.1-cp37-cp37m-win_amd64.whl (256.2 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pybison-0.3.1-cp38-cp38-macosx_10_14_x86_64.whl (136.9 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pybison-0.3.1-cp38-cp38-manylinux1_x86_64.whl (1.1 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pybison-0.3.1-cp38-cp38-manylinux2010_x86_64.whl (1.1 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pybison-0.3.1-cp38-cp38-win_amd64.whl (264.9 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pybison-0.3.1-cp39-cp39-macosx_10_14_x86_64.whl (137.4 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pybison-0.3.1-cp39-cp39-manylinux1_x86_64.whl (543.0 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pybison-0.3.1-cp39-cp39-manylinux2010_x86_64.whl (543.0 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pybison-0.3.1-cp39-cp39-win_amd64.whl (260.2 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pybison-0.3.1.tar.gz (34.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page