Hello Andi,
actually it seems to be handling function calls on the left wrong.
That's why I provided a better imlementation. Well we agreed way back
that we wanted to have something like this. Maybe the I have it wrong
in mind and we haven't really agreed on the exact behavior. But what
I remember is that we wanted ?: behave just like a shortcut. And that
is what I did. No with the new patch it works pretty fine. Patch is
attached.
best regards
marcus
Tuesday, March 6, 2007, 3:54:13 AM, you wrote:
> Did we agree on this? I don't remember we concluded this discussion.
> In any case, are you sure there's not a double free bug here? (Using $1
> twice?). While I haven't validated this, it seems to be buggy just by
> looking at it.
> Andi
>> -----Original Message-----
>> From: Marcus Boerger [mailto:helly@xxxxxxx]
>> Sent: Sunday, March 04, 2007 8:26 AM
>> To: zend-engine-cvs@xxxxxxxxxxxxx; phpdoc@xxxxxxxxxxxxx
>> Subject: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_language_parser.y
>>
>> helly Sun Mar 4 16:25:58 2007 UTC
>>
>> Modified files:
>> /ZendEngine2 zend_language_parser.y
>> Log:
>> - Implement '?:'
>> [DOC] "expr1 ?: expr1" is a shortcut for: "expr1 ? expr1 : expr2" as
>> exists in gcc and discussed some time back. Note that
>> this is not
>> an implementation ifsetor($var, default). While
>> ifsetor would not
>> generate any message for non existing variables or
>> array indices
>> the ternary shortcut does. Also the ternary shortcut
>> does a boolean
>> evaluation rather then checking for isset(). That way
>> ther ternary
>> shortcut can work on any expression while ifsetor can
>> only work on
>> variables. Also to be silent one has do do: "@$expr1
>> ?: $expr2".
>>
>>
>> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_language_parser
>> .y?r1=1.178&r2=1.179&diff_format=u
>> Index: ZendEngine2/zend_language_parser.y
>> diff -u ZendEngine2/zend_language_parser.y:1.178
>> ZendEngine2/zend_language_parser.y:1.179
>> --- ZendEngine2/zend_language_parser.y:1.178 Mon Jan 29 04:40:46 2007
>> +++ ZendEngine2/zend_language_parser.y Sun Mar 4 16:25:57 2007
>> @@ -18,7 +18,7 @@
>>
>> +-------------------------------------------------------------
>> ---------+
>> */
>>
>> -/* $Id: zend_language_parser.y,v 1.178 2007/01/29 04:40:46
>> iliaa Exp $ */
>> +/* $Id: zend_language_parser.y,v 1.179 2007/03/04 16:25:57
>> helly Exp $
>> +*/
>>
>> /*
>> * LALR shift/reduce conflicts and how they are resolved:
>> @@ -611,6 +611,9 @@
>> | expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
>> expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
>> expr { zend_do_qm_false(&$$, &$7, &$2, &$5
>> TSRMLS_CC); }
>> + | expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
>> + ':' { zend_do_qm_true(&$1, &$2, &$4 TSRMLS_CC); }
>> + expr { zend_do_qm_false(&$$, &$6, &$2, &$4
>> TSRMLS_CC); }
>> | internal_functions_in_yacc { $$ = $1; }
>> | T_INT_CAST expr { zend_do_cast(&$$,
>> &$2, IS_LONG TSRMLS_CC); }
>> | T_DOUBLE_CAST expr { zend_do_cast(&$$,
>> &$2, IS_DOUBLE TSRMLS_CC); }
>>
>> --
>> Zend Engine CVS Mailing List (http://cvs.php.net/) To
>> unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
Best regards,
Marcus
ze3-ternary-shortcut-20070306.diff.txt
Description: Text document
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|