Skip to main content

A lazy source code generation library

Project description

What is BrownBat ?

BrownBat is a pure Python library to create source code generators. By source code generator, I mean a program which outputs source code. Its main features are: * Laziness everywhere: you can set every possible name or attribute after the object has been created and used, and it will be taken into account when printed. This allows the generator to set the layout of the code, and for example set the names of the variables or functions later, when the correct name can be computed from another source of information.

  • Nifty operator overloading, making it quite easy to manipulate source code objects.

  • Automatic debugging comments for every object created. That means that when you create a variable and you print its definitionto an output source file, you will be able to tell which line in the Python generator created this variable. This is incredibly helpful when you are lost in your spaghetti code and you don’t even know from where that specific output source code line comes from, or just why this line of code shows up in the output.

It currently handles C langage, but adding new langages leveraging all the facilities given by the core should be easy.

Why would I want to generate some source code ?

Because it allows you to write custom tools to avoid repetitive or error prone tasks. A good example would be the generation of a serialization and deserialization routines for a C structure described in XML. This can be quite easily accomplished with the help of this library and the standard Python library.

Supported langages

Currently, only C langage is supported. That said, what makes this library interesting (laziness, operator overloading) is separated in a langage independent module (core), which should make it easy to add support for a new langage. A guide to write support code for new langages will be released in the next few months.

Installing

BrownBat requires Python 3 to work correctly. It can be installed from PyPI (Python package index):

> pip install brownbat

To install the beta version, use the –pre switch of pip.

Alternatively, the development version can be retrieved on Github: https://github.com/DouglasRaillard/BrownBat

How to use it ?

Documentation and guides will be made available in the next few month. It will include examples and a guide to implement support for a new langage (most of the hard work of operator overloading is inside a core module, which is langage independent).

License

BrownBat is licensed under the GNU Lesser General Public License v3 or later (LGPLv3+) License.

Why BrownBat is named BrownBat ?

Because those cute animals are very lazy (according to http://en.wikipedia.org/wiki/Little_brown_bat#Sleep, they can sleep up to 20h a day). And this library is designed to be lazy at its very core.

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

BrownBat-0.0b2.tar.gz (25.6 kB view hashes)

Uploaded Source

Built Distribution

BrownBat-0.0b2-py3-none-any.whl (27.7 kB view hashes)

Uploaded Python 3

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