php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #62164
Patch php-5.4.3-alt-try-catch.diff revision 2012-05-26 07:00 UTC by kriss at krizalys dot com

Patch php-5.4.3-alt-try-catch.diff for Scripting Engine problem Bug #62164

Patch version 2012-05-26 07:00 UTC

Return to Bug #62164 | Download this patch
Patch Revisions:

Developer: kriss@krizalys.com

diff --git a/php-5.4.3.orig/Zend/zend_language_parser.y b/php-5.4.3/Zend/zend_language_parser.y
index d0730b7..fc7ea5f 100644
--- a/php-5.4.3.orig/Zend/zend_language_parser.y
+++ b/php-5.4.3/Zend/zend_language_parser.y
@@ -50,7 +50,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
 %}
 
 %pure_parser
-%expect 3
+%expect 5
 
 %token END 0 "end of file"
 %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
@@ -159,6 +159,8 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
 %token T_CONST      "const (T_CONST)"
 %token T_RETURN     "return (T_RETURN)"
 %token T_TRY        "try (T_TRY)"
+%left T_ENDTRY
+%token T_ENDTRY     "endtry (T_ENDTRY)"
 %token T_CATCH      "catch (T_CATCH)"
 %token T_THROW      "throw (T_THROW)"
 %token T_USE        "use (T_USE)"
@@ -319,6 +321,12 @@ unticked_statement:
 		T_VARIABLE ')' { zend_do_begin_catch(&$1, &$9, &$11, &$7 TSRMLS_CC); }
 		'{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
 		additional_catches { zend_do_mark_last_catch(&$7, &$18 TSRMLS_CC); }
+	|	T_TRY { zend_do_try(&$1 TSRMLS_CC); } ':' inner_statement_list
+		T_CATCH '(' { zend_initialize_try_catch_element(&$1 TSRMLS_CC); }
+		fully_qualified_class_name { zend_do_first_catch(&$6 TSRMLS_CC); }
+		T_VARIABLE ')' { zend_do_begin_catch(&$1, &$8, &$10, &$6 TSRMLS_CC); }
+		':' inner_statement_list { zend_do_end_catch(&$1 TSRMLS_CC); }
+		additional_catches_colon { zend_do_mark_last_catch(&$6, &$16 TSRMLS_CC); } T_ENDTRY ';'
 	|	T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
 	|	T_GOTO T_STRING ';' { zend_do_goto(&$2 TSRMLS_CC); }
 ;
@@ -340,6 +348,22 @@ additional_catch:
 ;
 
 
+additional_catches_colon:
+		non_empty_additional_catches_colon { $$ = $1; }
+	|	/* empty */ { $$.u.op.opline_num = -1; }
+;
+
+non_empty_additional_catches_colon:
+		additional_catch_colon { $$ = $1; }
+	|	non_empty_additional_catches_colon additional_catch_colon { $$ = $2; }
+;
+
+
+additional_catch_colon:
+	T_CATCH '(' fully_qualified_class_name { $$.u.op.opline_num = get_next_op_number(CG(active_op_array)); } T_VARIABLE ')' { zend_do_begin_catch(&$1, &$3, &$5, NULL TSRMLS_CC); } ':' inner_statement_list { zend_do_end_catch(&$1 TSRMLS_CC); }
+;
+
+
 unset_variables:
 		unset_variable
 	|	unset_variables ',' unset_variable
diff --git a/php-5.4.3.orig/Zend/zend_language_scanner.l b/php-5.4.3/Zend/zend_language_scanner.l
index d530b53..5876ac3 100644
--- a/php-5.4.3.orig/Zend/zend_language_scanner.l
+++ b/php-5.4.3/Zend/zend_language_scanner.l
@@ -1030,6 +1030,10 @@ NEWLINE ("\r"|"\n"|"\r\n")
 	return T_TRY;
 }
 
+<ST_IN_SCRIPTING>"endtry" {
+	return T_ENDTRY;
+}
+
 <ST_IN_SCRIPTING>"catch" {
 	return T_CATCH;
 }
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC