[Python-Dev] ast-objects branch created

Jeremy Hylton jeremy at alum.mit.edu
Thu Dec 1 14:11:37 CET 2005


Martin,

I'm not sure what your intent for this work is, but I'd like to create
a parallel arena branch and compare the results.  I'll start work on
that tomorrow.

Jeremy

On 11/30/05, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> 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
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/jeremy%40alum.mit.edu
>


More information about the Python-Dev mailing list