I'm trying to add support to the AST compiler for decorators.  I'm
stuck in trying to represent them in ASDL.  This is what I currently
have:

        stmt = FunctionDef(decorator* decorators, identifier name,
                           arguments args, stmt* body)
             | ...

        decorator = (identifier name, arglist* args)

        
        arglist = ArgList(expr* args, keyword* keywords, expr? starargs,
                          expr? kwargs)
        

Although I have quite a bit of the implementation done, I don't like
the ArgList node.  Perhaps this would be better:

        stmt = FunctionDef(decorator* decorators, identifier name,
                           arguments args, stmt* body)
             | ...

        expr = CallExpr(call c)
             | ...

        decorator = DecoratorName(identifier name)
                  | DecoratorCall(call c)

        
        call = Call(expr func, expr* args, keyword* keywords,
                    expr? starargs, expr? kwargs)

A decorator call is basically a function call, the only difference
being that the func expression must be a dotted_name.  The second
definition seems fairly clumsy as well.  Any advice?

  Neil
_______________________________________________
Compiler-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/compiler-sig

Reply via email to