A library for defining and manipulating ASTs
Project description
# iAST #
(Supports Python 3.3 and 3.4)
This library provides a way of defining and transforming abstract syntax trees (ASTs) for custom languages. It can be used to help build a compiler or other program transformation system.
iAST reads your language’s abstract syntax from an ASDL grammar, and automatically generates node classes. A standard visitor-style framework is provided for traversing, transforming, and pattern matching over trees. Nodes are hashable, have structural equality, and support optional type checking. (Parsing is not supported and should be handled by an external parser generator.)
Node definitions for the ASTs of Python 3.3 and Python 3.4 are provided out-of-the-box, along with tools for writing code templates and macros targeting Python code. However, the main framework works on ASTs for arbitrary languages.
## Examples ##
See [arith.py](examples/arith.py) for basic usage and visitors/transformers. See [toy.py](examples/toy.py) for a comparison with Python’s own ast module and the use of type checking. Both examples use abstract grammars from the corresponding ASDL files.
## Installation ##
To install from pip/PyPI:
` python -m pip install iast `
To use a development version:
` python -m pip install https://github.com/brandjon/iast/tree/tarball/develop `
Python 3.3 and 3.4 are supported. The only dependency is [simplestruct](https://github.com/brandjon/simplestruct), which is used to define the node classes.
## Developers ##
Tests can be run with python setup.py test, or by installing [Tox](http://testrun.org/tox/latest/) and running python -m tox in the project root. Tox tests both Python 3.3 and 3.4 configurations. Building a source distribution (python setup.py sdist) requires the setuptools extension package [setuptools-git](https://github.com/wichert/setuptools-git).
## References ##
[1]: https://github.com/eliben/asdl_parser [[1]]: Eli Bendersky’s rewrite of the Python ASDL parser, which powers iAST’s generation of nodes from ASDL.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file iAST-0.2.0.zip
.
File metadata
- Download URL: iAST-0.2.0.zip
- Upload date:
- Size: 46.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b358ad211a8a8b194e3a2c6979c892bb7f5cb678dfe87b7773aa038f5fbcb17 |
|
MD5 | 70acaecc6bf49779e72d86a6f5915b8d |
|
BLAKE2b-256 | ae4f51cd418066e948acdee2ac65cd527f3ff1629b18ede898ace5e505312e7c |