Re: [RFC][Discussion] Parser extension API

From: Date: Wed, 18 Feb 2015 19:40:38 +0000
Subject: Re: [RFC][Discussion] Parser extension API
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-83111@lists.php.net to get a copy of this message
I want to attach a link to the Python AST documentation: https://docs.python.org/3.2/library/ast.html What I like there is iteration of nodes with generators (yields). NodeVisitor that can be extended and used as coroutine to simplify logic of traversal. I want to keep Node class as simple DTO with public properties, but only children field will be a generator. What do you think? 2015-02-18 22:34 GMT+03:00 Alexander Lisachenko <lisachenko.it@gmail.com>: > > 2015-02-18 22:22 GMT+03:00 Dmitry Stogov <dmitry@zend.com>: > >> I think the AST API shouldn't use "public" properties. >> Using it, we will have to construct the whole tree of objects, >> duplicating information from AST. >> I would propose SimpleXML approach instead - construct object only for >> node(s) we currently access. > > > What about Generators? They can be used nicely for handling AST data. And > each node can be constructed as needed during the traversal. Probably this > way is better than ArrayAccess >

« previous php.internals (#83111) next »