[pypy-issue] Issue #2054: Add the end of ast node to parser. (pypy/pypy)

enomad issues-reply at bitbucket.org
Wed May 27 15:07:26 CEST 2015


New issue 2054: Add the end of ast node to parser.
https://bitbucket.org/pypy/pypy/issue/2054/add-the-end-of-ast-node-to-parser

enomad:

Hi.

I want to do some contribution to [rope library](https://github.com/python-rope/rope). As I know it is the only library for code refactoring for python. To have ability to do code changes AST must have the offset of the end of statement. Now it is implemented by [ad-hoc](https://github.com/python-rope/rope/blob/master/rope/refactor/patchedast.py) and cant parse many of python sources.

I want to implement this feature on existing parser, and probably take pypy is good idea.

I have already added to Python.asdl extra attributes, created [script](https://gist.github.com/enomado/f7c1e6702ae2fb03156c) to test my changes. Now I'm adding to [astbuilder](https://bitbucket.org/pypy/pypy/src/default/pypy/interpreter/astcompiler/astbuilder.py)  something like 

```
#!python
node = traverse(value_child)
return ast.Assign(targets, value_expr, stmt.lineno, stmt.column, node.lineno, node.column+len(node.value))
```

**And now i want to ask for advice.** 
1. Should I do standalone fork of pypy's parser OR it can be merged to pypy ? 
2. My be I'm doing something needless ?




More information about the pypy-issue mailing list