Full Syntax Tree for python to make writing refactoring code a realist task
Likely abandoned. No release or commit for years (last release over 4 years ago).
pip install baronIntroduction
Baron is a Full Syntax Tree (FST) library for Python. By opposition to an AST which
drops some syntax information in the process of its creation (like empty lines,
comments, formatting), a FST keeps everything and guarantees the operation
fst_to_code(code_to_fst(source_code)) == source_code.
Roadmap
Current roadmap is as boring as needed:
- bug fixs
- new small features (walker pattern, maybe code generation) and performance improvement.
Installation
pip install baron
Basic Usage
from baron import parse, dumps
fst = parse(source_code_string)
source_code_string == dumps(fst)
Unless you want to do low level things, use RedBaron instead of using Baron directly. Think of Baron as the "bytecode of python source code" and RedBaron as some sort of usable layer on top of it.
If you don't know what Baron is or don't understand yet why it might be useful for you, read the « Why is this important? » section.
Documentation
Baron documentation is available on Read The Docs.
Contributing
If you want to implement new grammar elements for newer python versions, here are the documented steps for that: https://github.com/PyCQA/baron/blob/master/add_new_grammar.md
Also note that reviewing most grammar modifications takes several hours of advanced focusing (we can't really afford bugs here) so don't despair if you PR seems to be hanging around, sorry for that :/
And thanks in advance for your work!
Financial support
Baron and RedBaron are a very advanced piece of engineering that requires a lot of time of concentration to work on. Until the end of 2018, the development has been a full volunteer work mostly done by Bram, but now, to reach the next level and bring those projects to the stability and quality you expect, we need your support.
You can join our contributors and sponsors on our transparent OpenCollective, every contribution will count and will be mainly used to work on the projects stability and quality but also on continuing, on the side, the R&D side of those projects.