Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56683 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74882 invoked from network); 30 Nov 2011 18:09:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2011 18:09:15 -0000 Authentication-Results: pb1.pair.com header.from=ralph@ralphschindler.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ralph@ralphschindler.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ralphschindler.com from 209.85.160.170 cause and error) X-PHP-List-Original-Sender: ralph@ralphschindler.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:34327] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/4A-17272-54176DE4 for ; Wed, 30 Nov 2011 13:09:15 -0500 Received: by ghbg16 with SMTP id g16so1057203ghb.29 for ; Wed, 30 Nov 2011 10:09:03 -0800 (PST) Received: by 10.236.76.136 with SMTP id b8mr5836903yhe.9.1322676543329; Wed, 30 Nov 2011 10:09:03 -0800 (PST) Received: from ralph-mac.local (ip174-73-14-247.no.no.cox.net. [174.73.14.247]) by mx.google.com with ESMTPS id r4sm7541144anl.5.2011.11.30.10.09.02 (version=SSLv3 cipher=OTHER); Wed, 30 Nov 2011 10:09:02 -0800 (PST) Message-ID: <4ED6713D.2050009@ralphschindler.com> Date: Wed, 30 Nov 2011 12:09:01 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: internals Content-Type: multipart/mixed; boundary="------------040806050003050505050909" Subject: 5.4's New De-referencing plus assignment From: ralph@ralphschindler.com (Ralph Schindler) --------------040806050003050505050909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hey all (Filipe), This was brought up in the thread "New dereferencing syntaxes in 5.4". I too think this would be beneficial: $value = ($obj = new Foo)->produceAValue(); but the current parser (branch 5.4) doesn't have a rule for this. I've attached a quick/working patch, but I don't fully understand the ramifications of such a patch. Can someone explain the drawbacks of increasing the "%expect n" for me? Would this many s/r require/benefit from a new expression grouping? More to the point, can we have this small change for 5.4? Thanks in advance. -ralph --------------040806050003050505050909 Content-Type: text/plain; name="new-plus-call-plus-assign.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="new-plus-call-plus-assign.patch.txt" diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index a0c671b..f777b36 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -50,7 +50,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %} %pure_parser -%expect 3 +%expect 4 %token END 0 "end of file" %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE @@ -772,6 +772,7 @@ expr_without_variable: | expr T_INSTANCEOF class_name_reference { zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); } | '(' expr ')' { $$ = $2; } | new_expr { $$ = $1; } + | '(' variable '=' new_expr ')' { zend_check_writable_variable(&$2); zend_do_assign(&$$, &$2, &$4 TSRMLS_CC); } instance_call { $$ = $7; } | '(' new_expr ')' { $$ = $2; } instance_call { $$ = $5; } | expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); } expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); } --------------040806050003050505050909--