[Python-Dev] [Python-projects] AST in Python 2.5
Nicolas Chauvat
nicolas.chauvat at logilab.fr
Thu Feb 16 09:57:00 CET 2006
On Wed, Feb 15, 2006 at 09:40:17PM -0800, Neal Norwitz wrote:
> I'm not sure if anyone here is following the AST discussion on
> python-dev, but it would be great if you had any input. pylint is a
> pretty big consumer of the compiler module and the decisions with
> respect to the AST could impact you.
>
> http://mail.python.org/pipermail/python-dev/2006-February/060994.html
We will jump in with better comments, but I just wanted to make sure
you knew about:
http://www.logilab.org/projects/astng
and the work being done in PyPy:
http://codespeak.net/pypy/dist/pypy/doc/parser.html
http://codespeak.net/pypy/dist/pypy/module/recparser/
http://codespeak.net/pypy/dist/pypy/doc/interpreter.html
http://codespeak.net/pypy/dist/pypy/interpreter/astcompiler/
Here is a bit from our EU reports that is about Workpackage 10
"Aspects and Contracts in Python":
WP10 Status
===========
Extend language with aspects and contracts
* researched how other languages do it (AspectJ, HyperJ, AspectS, etc.)
* started allowing AST manipulation (for weaving code and function calls)
* started allowing grammar manipulation (for experimenting with syntax)
WP10 Status (cont.)
===================
AST and grammar manipulation
* needed for both WP9 and WP10
* AST nodes are exposed at application-level and a compiler hook
* allows to modify the AST at compile-time
* syntax can be modified at run-time, but still limited because
grammar objects are not fully exposed at application-level
WP10 Status (cont.)
===================
AST manipulation example::
>>>> 3 + 3
6
>>>> from parser import install_compiler_hook
>>>> from hooks import _3becomes2
>>>> install_compiler_hook(_3becomes2)
>>>> 3 + 3
4
>>>>
--
Nicolas Chauvat
logilab.fr - services en informatique avancée et gestion de connaissances
More information about the Python-Dev
mailing list