] > Re: [ANN] ASTNG 0.13.1 (Logilab.org)

Email Re: [ANN] ASTNG 0.13.1

from
to
subject
Re: [ANN] ASTNG 0.13.1
date
2005/11/08 08:23
On 11/8/05, Sylvain Thénault <sylvain.thenault@logilab.fr> wrote:
> On Monday 07 November à 13:33, Jeremy Hylton wrote:
> > Have you given any thought about how the compiler.ast module should be
> > intergrated with the new AST in the C Python compiler?  It seems like
> > the two ought to be unified and that the C Python AST ought to be
> > exposed to Python programs.  I'm not sure how to actually accomplish
> > this, though.
>
> It's a long time since I want to take a look at the AST branch of the
> python C compiler but unfortunatly didn't had the time to do so yet.
> Do you have any hint about where should I look first ? Do you know if

The file to look at is Python/Parser.asdl in the svn repository.  The
chief difference between the old and new ASTs is that the new AST is
typed.  Consider this fragment:

stmt = FunctionDef(identifier name, arguments args,
                           stmt* body, expr* decorators)
      | ClassDef(identifier name, expr* bases, stmt* body)
      | Return(expr? value)

The child nodes of a function definition are typed-- the body is a
sequence of zero or more statements, the decorators are a sequence of
zero or more expressions.  I'm sure the names of nodes are slightly
different, too.

Assignment is restructured a bit.  There are two types -- Assign and
AugAssign.  The node type doesn't distinguish among assignments to
different types (attr, list, name).  The expressions that can appear
in an assignment context have an extra flag to indicate how they are
to be used (load, store, del, and augmented versions of these).

> there is a lot of differences between python and compiler.ast nodes?
> It would definitly be a great win to use the C Python ast for pylint
> with python >= 2.5...

I think the chief advantage is that we ought to be able to emit the
AST directly from the compiler to Python code -- like the parser
module.

Jeremy


is a reply to