Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83111 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25040 invoked from network); 18 Feb 2015 19:40:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 19:40:44 -0000 Authentication-Results: pb1.pair.com header.from=lisachenko.it@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=lisachenko.it@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: lisachenko.it@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:44543] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/B6-25021-ABAE4E45 for ; Wed, 18 Feb 2015 14:40:43 -0500 Received: by mail-wi0-f174.google.com with SMTP id em10so43490519wid.1 for ; Wed, 18 Feb 2015 11:40:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=9gQ6kj5ciPVw7xheHCgRCI2DTAfO4cFZSEhSdUZQVko=; b=wFgMbj6eqvhjzPQbnhqh6+yQwB9Yu3EWJmksoOOqex5pEc5oNCH/TQBdYz4sPRKZ5m JzPSK1sPjobv0vcVDdX5Vugi3HSLoTurQCf2QKOxnPc7+Azwauwv4tW9PFftCfI/cSJu BNhyJknDlk+VszJtlEI9lVSV+z1/eD/VuseC+0G+8Qk2yQT817z8HPnD3itWTtWZQaRD DFg1+VGJxMhbnkXkGv6muQJERXXfXjybkGuRjk5xiMGj5qUsmNqXPdaouLzNc0mI16yb DdJ0n4Y0igVKbG0jVqE6LczkVsdLxQpAsk14oYg82wLKFz1Rp45QqFh7vvbWwu8X0iLV 0njw== MIME-Version: 1.0 X-Received: by 10.194.75.193 with SMTP id e1mr1795946wjw.126.1424288438772; Wed, 18 Feb 2015 11:40:38 -0800 (PST) Received: by 10.194.154.229 with HTTP; Wed, 18 Feb 2015 11:40:38 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Feb 2015 23:40:38 +0400 Message-ID: To: Dmitry Stogov Cc: Nikita Popov , Nikita Popov , PHP internals list Content-Type: multipart/alternative; boundary=047d7bb03ea8736875050f61fe63 Subject: Re: [PHP-DEV] [RFC][Discussion] Parser extension API From: lisachenko.it@gmail.com (Alexander Lisachenko) --047d7bb03ea8736875050f61fe63 Content-Type: text/plain; charset=UTF-8 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 : > > 2015-02-18 22:22 GMT+03:00 Dmitry Stogov : > >> 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 > --047d7bb03ea8736875050f61fe63--