[Python-Dev] ast-objects branch created

"Martin v. Löwis" martin at v.loewis.de
Thu Dec 1 00:12:48 CET 2005


I created
http://svn.python.org/projects/python/branches/ast-objects/
You can convert your repository to that branch with
svn switch svn+ssh://pythondev@svn.python.org/python/branches/ast-objects
in the toplevel directory. In particular, this features
http://svn.python.org/projects/python/branches/ast-objects/Parser/asdl_c.py
http://svn.python.org/projects/python/branches/ast-objects/Include/Python-ast.h
http://svn.python.org/projects/python/branches/ast-objects/Python/Python-ast.c
The status is currently this:
- asdl_c generates a type hierarchy: "Sum" productions have one type
 per constructor, inheriting from a type for the sum; plain products
 only have a type for the product.
- attributes are in the base type, accessible through o->_base.attr;
 projections of the product types are accessible directly through
 member names.
- all projections must be non-NULL. Sequences are represented through
 potentially empty lists; optional types are potentially represented
 through Py_None. bool is gone; use Py_True/Py_False. The only
 primitive type remaining is int (which only occurs in lineno)
- the types currently have only a constructor, a dealloc function,
 and an _Check macro.
- Naming is this: for cross-object-file visible symbols (functions
 and global variables), a Py_ prefix is used. Otherwise, I use
 the type name or constructor name directly. There is a #define
 for the Py_<type>_New function, so you can also write <type>(params).
 Parameter order for the types is: projections first, then
 attributes.
- For compatibility with the current code, the Sum base types
 also have the _kind enumeration (although that appears not
 to get initialized right now).
For asdl_c, I see the following things as TODOs:
- add support for traversing the types from C, through tp_members
 (read-only). Optionally add support for pickling.
- add support for garbage collection. I don't expect this to be
 necessary right now, but will be if the API is exposed, and it
 doesn't cost much.
The bigger chunk of necessary changes is in using these, starting
with ast.c.
Feel free to commit any changes to that branch that you consider
helpful. To avoid duplicated work, posting a note here might
also help.
Regards,
Martin


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /