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

Windows

With Chocolatey, you can install the packages as follows:

choco install winflexbison3

Additionally, if a C compiler is needed, mingw can be installed with Chocolatey as well.

choco install mingw

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.

Source Distribution

pybison-0.6.3.tar.gz (35.8 kB view hashes)

Uploaded Source

Built Distributions

pybison-0.6.3-cp311-cp311-win_amd64.whl (376.6 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

pybison-0.6.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (573.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

pybison-0.6.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl (573.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64 manylinux: glibc 2.24+ ARM64

pybison-0.6.3-cp311-cp311-macosx_11_0_arm64.whl (242.1 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

pybison-0.6.3-cp311-cp311-macosx_10_9_x86_64.whl (261.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pybison-0.6.3-cp310-cp310-win_amd64.whl (269.7 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pybison-0.6.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (455.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

pybison-0.6.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl (449.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64 manylinux: glibc 2.24+ ARM64

pybison-0.6.3-cp310-cp310-macosx_11_0_arm64.whl (243.1 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

pybison-0.6.3-cp310-cp310-macosx_10_9_x86_64.whl (153.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pybison-0.6.3-cp39-cp39-win_amd64.whl (379.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pybison-0.6.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (690.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pybison-0.6.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (692.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

pybison-0.6.3-cp39-cp39-macosx_11_0_arm64.whl (246.7 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

pybison-0.6.3-cp39-cp39-macosx_10_9_x86_64.whl (265.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pybison-0.6.3-cp38-cp38-win_amd64.whl (383.0 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pybison-0.6.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (712.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pybison-0.6.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (713.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

pybison-0.6.3-cp38-cp38-macosx_11_0_arm64.whl (245.8 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

pybison-0.6.3-cp38-cp38-macosx_10_9_x86_64.whl (266.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

pybison-0.6.3-cp37-cp37m-win_amd64.whl (375.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pybison-0.6.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (522.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pybison-0.6.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (520.3 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

pybison-0.6.3-cp37-cp37m-macosx_10_9_x86_64.whl (261.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page