xref: /PHP-5.5/Zend/zend_language_parser.y (revision cc70a465)
1 %{
2 /*
3    +----------------------------------------------------------------------+
4    | Zend Engine                                                          |
5    +----------------------------------------------------------------------+
6    | Copyright (c) 1998-2015 Zend Technologies Ltd. (http://www.zend.com) |
7    +----------------------------------------------------------------------+
8    | This source file is subject to version 2.00 of the Zend license,     |
9    | that is bundled with this package in the file LICENSE, and is        |
10    | available through the world-wide-web at the following url:           |
11    | http://www.zend.com/license/2_00.txt.                                |
12    | If you did not receive a copy of the Zend license and are unable to  |
13    | obtain it through the world-wide-web, please send a note to          |
14    | license@zend.com so we can mail you a copy immediately.              |
15    +----------------------------------------------------------------------+
16    | Authors: Andi Gutmans <andi@zend.com>                                |
17    |          Zeev Suraski <zeev@zend.com>                                |
18    +----------------------------------------------------------------------+
19 */
20 
21 /* $Id$ */
22 
23 /*
24  * LALR shift/reduce conflicts and how they are resolved:
25  *
26  * - 2 shift/reduce conflicts due to the dangling elseif/else ambiguity. Solved by shift.
27  *
28  */
29 
30 
31 #include "zend_compile.h"
32 #include "zend.h"
33 #include "zend_list.h"
34 #include "zend_globals.h"
35 #include "zend_API.h"
36 #include "zend_constants.h"
37 
38 #define YYSIZE_T size_t
39 #define yytnamerr zend_yytnamerr
40 static YYSIZE_T zend_yytnamerr(char*, const char*);
41 
42 #define YYERROR_VERBOSE
43 #define YYSTYPE znode
44 
45 %}
46 
47 %pure_parser
48 %expect 3
49 
50 %code requires {
51 #ifdef ZTS
52 # define YYPARSE_PARAM tsrm_ls
53 # define YYLEX_PARAM tsrm_ls
54 #endif
55 }
56 
57 %token END 0 "end of file"
58 %left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
59 %token T_INCLUDE      "include (T_INCLUDE)"
60 %token T_INCLUDE_ONCE "include_once (T_INCLUDE_ONCE)"
61 %token T_EVAL         "eval (T_EVAL)"
62 %token T_REQUIRE      "require (T_REQUIRE)"
63 %token T_REQUIRE_ONCE "require_once (T_REQUIRE_ONCE)"
64 %left ','
65 %left T_LOGICAL_OR
66 %token T_LOGICAL_OR   "or (T_LOGICAL_OR)"
67 %left T_LOGICAL_XOR
68 %token T_LOGICAL_XOR  "xor (T_LOGICAL_XOR)"
69 %left T_LOGICAL_AND
70 %token T_LOGICAL_AND  "and (T_LOGICAL_AND)"
71 %right T_PRINT
72 %token T_PRINT        "print (T_PRINT)"
73 %right T_YIELD
74 %token T_YIELD        "yield (T_YIELD)"
75 %left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL
76 %token T_PLUS_EQUAL   "+= (T_PLUS_EQUAL)"
77 %token T_MINUS_EQUAL  "-= (T_MINUS_EQUAL)"
78 %token T_MUL_EQUAL    "*= (T_MUL_EQUAL)"
79 %token T_DIV_EQUAL    "/= (T_DIV_EQUAL)"
80 %token T_CONCAT_EQUAL ".= (T_CONCAT_EQUAL)"
81 %token T_MOD_EQUAL    "%= (T_MOD_EQUAL)"
82 %token T_AND_EQUAL    "&= (T_AND_EQUAL)"
83 %token T_OR_EQUAL     "|= (T_OR_EQUAL)"
84 %token T_XOR_EQUAL    "^= (T_XOR_EQUAL)"
85 %token T_SL_EQUAL     "<<= (T_SL_EQUAL)"
86 %token T_SR_EQUAL     ">>= (T_SR_EQUAL)"
87 %left '?' ':'
88 %left T_BOOLEAN_OR
89 %token T_BOOLEAN_OR   "|| (T_BOOLEAN_OR)"
90 %left T_BOOLEAN_AND
91 %token T_BOOLEAN_AND  "&& (T_BOOLEAN_AND)"
92 %left '|'
93 %left '^'
94 %left '&'
95 %nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
96 %token T_IS_EQUAL     "== (T_IS_EQUAL)"
97 %token T_IS_NOT_EQUAL "!= (T_IS_NOT_EQUAL)"
98 %token T_IS_IDENTICAL "=== (T_IS_IDENTICAL)"
99 %token T_IS_NOT_IDENTICAL "!== (T_IS_NOT_IDENTICAL)"
100 %nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
101 %token T_IS_SMALLER_OR_EQUAL "<= (T_IS_SMALLER_OR_EQUAL)"
102 %token T_IS_GREATER_OR_EQUAL ">= (T_IS_GREATER_OR_EQUAL)"
103 %left T_SL T_SR
104 %token T_SL "<< (T_SL)"
105 %token T_SR ">> (T_SR)"
106 %left '+' '-' '.'
107 %left '*' '/' '%'
108 %right '!'
109 %nonassoc T_INSTANCEOF
110 %token T_INSTANCEOF  "instanceof (T_INSTANCEOF)"
111 %right '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
112 %token T_INC "++ (T_INC)"
113 %token T_DEC "-- (T_DEC)"
114 %token T_INT_CAST    "(int) (T_INT_CAST)"
115 %token T_DOUBLE_CAST "(double) (T_DOUBLE_CAST)"
116 %token T_STRING_CAST "(string) (T_STRING_CAST)"
117 %token T_ARRAY_CAST  "(array) (T_ARRAY_CAST)"
118 %token T_OBJECT_CAST "(object) (T_OBJECT_CAST)"
119 %token T_BOOL_CAST   "(bool) (T_BOOL_CAST)"
120 %token T_UNSET_CAST  "(unset) (T_UNSET_CAST)"
121 %right '['
122 %nonassoc T_NEW T_CLONE
123 %token T_NEW       "new (T_NEW)"
124 %token T_CLONE     "clone (T_CLONE)"
125 %token T_EXIT      "exit (T_EXIT)"
126 %token T_IF        "if (T_IF)"
127 %left T_ELSEIF
128 %token T_ELSEIF    "elseif (T_ELSEIF)"
129 %left T_ELSE
130 %token T_ELSE      "else (T_ELSE)"
131 %left T_ENDIF
132 %token T_ENDIF     "endif (T_ENDIF)"
133 %token T_LNUMBER   "integer number (T_LNUMBER)"
134 %token T_DNUMBER   "floating-point number (T_DNUMBER)"
135 %token T_STRING    "identifier (T_STRING)"
136 %token T_STRING_VARNAME "variable name (T_STRING_VARNAME)"
137 %token T_VARIABLE  "variable (T_VARIABLE)"
138 %token T_NUM_STRING "number (T_NUM_STRING)"
139 %token T_INLINE_HTML
140 %token T_CHARACTER
141 %token T_BAD_CHARACTER
142 %token T_ENCAPSED_AND_WHITESPACE  "quoted-string and whitespace (T_ENCAPSED_AND_WHITESPACE)"
143 %token T_CONSTANT_ENCAPSED_STRING "quoted-string (T_CONSTANT_ENCAPSED_STRING)"
144 %token T_ECHO       "echo (T_ECHO)"
145 %token T_DO         "do (T_DO)"
146 %token T_WHILE      "while (T_WHILE)"
147 %token T_ENDWHILE   "endwhile (T_ENDWHILE)"
148 %token T_FOR        "for (T_FOR)"
149 %token T_ENDFOR     "endfor (T_ENDFOR)"
150 %token T_FOREACH    "foreach (T_FOREACH)"
151 %token T_ENDFOREACH "endforeach (T_ENDFOREACH)"
152 %token T_DECLARE    "declare (T_DECLARE)"
153 %token T_ENDDECLARE "enddeclare (T_ENDDECLARE)"
154 %token T_AS         "as (T_AS)"
155 %token T_SWITCH     "switch (T_SWITCH)"
156 %token T_ENDSWITCH  "endswitch (T_ENDSWITCH)"
157 %token T_CASE       "case (T_CASE)"
158 %token T_DEFAULT    "default (T_DEFAULT)"
159 %token T_BREAK      "break (T_BREAK)"
160 %token T_CONTINUE   "continue (T_CONTINUE)"
161 %token T_GOTO       "goto (T_GOTO)"
162 %token T_FUNCTION   "function (T_FUNCTION)"
163 %token T_CONST      "const (T_CONST)"
164 %token T_RETURN     "return (T_RETURN)"
165 %token T_TRY        "try (T_TRY)"
166 %token T_CATCH      "catch (T_CATCH)"
167 %token T_FINALLY    "finally (T_FINALLY)"
168 %token T_THROW      "throw (T_THROW)"
169 %token T_USE        "use (T_USE)"
170 %token T_INSTEADOF  "insteadof (T_INSTEADOF)"
171 %token T_GLOBAL     "global (T_GLOBAL)"
172 %right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
173 %token T_STATIC     "static (T_STATIC)"
174 %token T_ABSTRACT   "abstract (T_ABSTRACT)"
175 %token T_FINAL      "final (T_FINAL)"
176 %token T_PRIVATE    "private (T_PRIVATE)"
177 %token T_PROTECTED  "protected (T_PROTECTED)"
178 %token T_PUBLIC     "public (T_PUBLIC)"
179 %token T_VAR        "var (T_VAR)"
180 %token T_UNSET      "unset (T_UNSET)"
181 %token T_ISSET      "isset (T_ISSET)"
182 %token T_EMPTY      "empty (T_EMPTY)"
183 %token T_HALT_COMPILER "__halt_compiler (T_HALT_COMPILER)"
184 %token T_CLASS      "class (T_CLASS)"
185 %token T_TRAIT      "trait (T_TRAIT)"
186 %token T_INTERFACE  "interface (T_INTERFACE)"
187 %token T_EXTENDS    "extends (T_EXTENDS)"
188 %token T_IMPLEMENTS "implements (T_IMPLEMENTS)"
189 %token T_OBJECT_OPERATOR "-> (T_OBJECT_OPERATOR)"
190 %token T_DOUBLE_ARROW    "=> (T_DOUBLE_ARROW)"
191 %token T_LIST            "list (T_LIST)"
192 %token T_ARRAY           "array (T_ARRAY)"
193 %token T_CALLABLE        "callable (T_CALLABLE)"
194 %token T_CLASS_C         "__CLASS__ (T_CLASS_C)"
195 %token T_TRAIT_C         "__TRAIT__ (T_TRAIT_C)"
196 %token T_METHOD_C        "__METHOD__ (T_METHOD_C)"
197 %token T_FUNC_C          "__FUNCTION__ (T_FUNC_C)"
198 %token T_LINE            "__LINE__ (T_LINE)"
199 %token T_FILE            "__FILE__ (T_FILE)"
200 %token T_COMMENT         "comment (T_COMMENT)"
201 %token T_DOC_COMMENT     "doc comment (T_DOC_COMMENT)"
202 %token T_OPEN_TAG        "open tag (T_OPEN_TAG)"
203 %token T_OPEN_TAG_WITH_ECHO "open tag with echo (T_OPEN_TAG_WITH_ECHO)"
204 %token T_CLOSE_TAG       "close tag (T_CLOSE_TAG)"
205 %token T_WHITESPACE      "whitespace (T_WHITESPACE)"
206 %token T_START_HEREDOC   "heredoc start (T_START_HEREDOC)"
207 %token T_END_HEREDOC     "heredoc end (T_END_HEREDOC)"
208 %token T_DOLLAR_OPEN_CURLY_BRACES "${ (T_DOLLAR_OPEN_CURLY_BRACES)"
209 %token T_CURLY_OPEN      "{$ (T_CURLY_OPEN)"
210 %token T_PAAMAYIM_NEKUDOTAYIM ":: (T_PAAMAYIM_NEKUDOTAYIM)"
211 %token T_NAMESPACE       "namespace (T_NAMESPACE)"
212 %token T_NS_C            "__NAMESPACE__ (T_NS_C)"
213 %token T_DIR             "__DIR__ (T_DIR)"
214 %token T_NS_SEPARATOR    "\\ (T_NS_SEPARATOR)"
215 
216 %% /* Rules */
217 
218 start:
219 	top_statement_list	{ zend_do_end_compilation(TSRMLS_C); }
220 ;
221 
222 top_statement_list:
223 		top_statement_list  { zend_do_extended_info(TSRMLS_C); } top_statement { HANDLE_INTERACTIVE(); }
224 	|	/* empty */
225 ;
226 
227 namespace_name:
228 		T_STRING { $$ = $1; }
229 	|	namespace_name T_NS_SEPARATOR T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
230 ;
231 
232 top_statement:
233 		statement						{ zend_verify_namespace(TSRMLS_C); }
234 	|	function_declaration_statement	{ zend_verify_namespace(TSRMLS_C); zend_do_early_binding(TSRMLS_C); }
235 	|	class_declaration_statement		{ zend_verify_namespace(TSRMLS_C); zend_do_early_binding(TSRMLS_C); }
236 	|	T_HALT_COMPILER '(' ')' ';'		{ zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; }
237 	|	T_NAMESPACE namespace_name ';'	{ zend_do_begin_namespace(&$2, 0 TSRMLS_CC); }
238 	|	T_NAMESPACE namespace_name '{'	{ zend_do_begin_namespace(&$2, 1 TSRMLS_CC); }
239 		top_statement_list '}'		    { zend_do_end_namespace(TSRMLS_C); }
240 	|	T_NAMESPACE '{'					{ zend_do_begin_namespace(NULL, 1 TSRMLS_CC); }
241 		top_statement_list '}'			{ zend_do_end_namespace(TSRMLS_C); }
242 	|	T_USE use_declarations ';'      { zend_verify_namespace(TSRMLS_C); }
243 	|	constant_declaration ';'		{ zend_verify_namespace(TSRMLS_C); }
244 ;
245 
246 use_declarations:
247 		use_declarations ',' use_declaration
248 	|	use_declaration
249 ;
250 
251 use_declaration:
252 		namespace_name 			{ zend_do_use(&$1, NULL TSRMLS_CC); }
253 	|	namespace_name T_AS T_STRING	{ zend_do_use(&$1, &$3 TSRMLS_CC); }
254 	|	T_NS_SEPARATOR namespace_name { zend_do_use(&$2, NULL TSRMLS_CC); }
255 	|	T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use(&$2, &$4 TSRMLS_CC); }
256 ;
257 
258 constant_declaration:
259 		constant_declaration ',' T_STRING '=' static_scalar	{ zend_do_declare_constant(&$3, &$5 TSRMLS_CC); }
260 	|	T_CONST T_STRING '=' static_scalar { zend_do_declare_constant(&$2, &$4 TSRMLS_CC); }
261 ;
262 
263 inner_statement_list:
264 		inner_statement_list  { zend_do_extended_info(TSRMLS_C); } inner_statement { HANDLE_INTERACTIVE(); }
265 	|	/* empty */
266 ;
267 
268 
269 inner_statement:
270 		statement
271 	|	function_declaration_statement
272 	|	class_declaration_statement
273 	|	T_HALT_COMPILER '(' ')' ';'   { zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope"); }
274 ;
275 
276 
277 statement:
278 		unticked_statement { DO_TICKS(); }
279 	|	T_STRING ':' { zend_do_label(&$1 TSRMLS_CC); }
280 ;
281 
282 unticked_statement:
283 		'{' inner_statement_list '}'
284 	|	T_IF parenthesis_expr { zend_do_if_cond(&$2, &$1 TSRMLS_CC); } statement { zend_do_if_after_statement(&$1, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); }
285 	|	T_IF parenthesis_expr ':' { zend_do_if_cond(&$2, &$1 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$1, 1 TSRMLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(TSRMLS_C); }
286 	|	T_WHILE { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); } parenthesis_expr { zend_do_while_cond(&$3, &$$ TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$4 TSRMLS_CC); }
287 	|	T_DO { $1.u.op.opline_num = get_next_op_number(CG(active_op_array));  zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE { $4.u.op.opline_num = get_next_op_number(CG(active_op_array)); } parenthesis_expr ';' { zend_do_do_while_end(&$1, &$4, &$6 TSRMLS_CC); }
288 	|	T_FOR
289 			'('
290 				for_expr
291 			';' { zend_do_free(&$3 TSRMLS_CC); $4.u.op.opline_num = get_next_op_number(CG(active_op_array)); }
292 				for_expr
293 			';' { zend_do_extended_info(TSRMLS_C); zend_do_for_cond(&$6, &$7 TSRMLS_CC); }
294 				for_expr
295 			')' { zend_do_free(&$9 TSRMLS_CC); zend_do_for_before_statement(&$4, &$7 TSRMLS_CC); }
296 			for_statement { zend_do_for_end(&$7 TSRMLS_CC); }
297 	|	T_SWITCH parenthesis_expr	{ zend_do_switch_cond(&$2 TSRMLS_CC); } switch_case_list { zend_do_switch_end(&$4 TSRMLS_CC); }
298 	|	T_BREAK ';'				{ zend_do_brk_cont(ZEND_BRK, NULL TSRMLS_CC); }
299 	|	T_BREAK expr ';'		{ zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); }
300 	|	T_CONTINUE ';'			{ zend_do_brk_cont(ZEND_CONT, NULL TSRMLS_CC); }
301 	|	T_CONTINUE expr ';'		{ zend_do_brk_cont(ZEND_CONT, &$2 TSRMLS_CC); }
302 	|	T_RETURN ';'						{ zend_do_return(NULL, 0 TSRMLS_CC); }
303 	|	T_RETURN expr_without_variable ';'	{ zend_do_return(&$2, 0 TSRMLS_CC); }
304 	|	T_RETURN variable ';'				{ zend_do_return(&$2, 1 TSRMLS_CC); }
305 	|	yield_expr ';' { zend_do_free(&$1 TSRMLS_CC); }
306 	|	T_GLOBAL global_var_list ';'
307 	|	T_STATIC static_var_list ';'
308 	|	T_ECHO echo_expr_list ';'
309 	|	T_INLINE_HTML			{ zend_do_echo(&$1 TSRMLS_CC); }
310 	|	expr ';'				{ zend_do_free(&$1 TSRMLS_CC); }
311 	|	T_UNSET '(' unset_variables ')' ';'
312 	|	T_FOREACH '(' variable T_AS
313 		{ zend_do_foreach_begin(&$1, &$2, &$3, &$4, 1 TSRMLS_CC); }
314 		foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
315 		foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); }
316 	|	T_FOREACH '(' expr_without_variable T_AS
317 		{ zend_do_foreach_begin(&$1, &$2, &$3, &$4, 0 TSRMLS_CC); }
318 		foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
319 		foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); }
320 	|	T_DECLARE { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_declare_begin(TSRMLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end(&$1 TSRMLS_CC); }
321 	|	';'		/* empty statement */
322 	|	T_TRY { zend_do_try(&$1 TSRMLS_CC); } '{' inner_statement_list '}'
323 		catch_statement { zend_do_bind_catch(&$1, &$6 TSRMLS_CC); }
324 		finally_statement { zend_do_end_finally(&$1, &$6, &$8 TSRMLS_CC); }
325 	|	T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
326 	|	T_GOTO T_STRING ';' { zend_do_goto(&$2 TSRMLS_CC); }
327 ;
328 
329 catch_statement:
330 				/* empty */ { $$.op_type = IS_UNUSED; }
331 	|	T_CATCH '(' { zend_initialize_try_catch_element(&$1 TSRMLS_CC); }
332 		fully_qualified_class_name { zend_do_first_catch(&$2 TSRMLS_CC); }
333 		T_VARIABLE ')' { zend_do_begin_catch(&$1, &$4, &$6, &$2 TSRMLS_CC); }
334 		'{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
335 		additional_catches { zend_do_mark_last_catch(&$2, &$13 TSRMLS_CC); $$ = $1;}
336 
337 finally_statement:
338 					/* empty */ { $$.op_type = IS_UNUSED; }
339 	|	T_FINALLY { zend_do_finally(&$1 TSRMLS_CC); } '{' inner_statement_list '}' { $$ = $1; }
340 ;
341 
342 additional_catches:
343 		non_empty_additional_catches { $$ = $1; }
344 	|	/* empty */ { $$.u.op.opline_num = -1; }
345 ;
346 
347 non_empty_additional_catches:
348 		additional_catch { $$ = $1; }
349 	|	non_empty_additional_catches additional_catch { $$ = $2; }
350 ;
351 
352 additional_catch:
353 	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); }
354 ;
355 
356 unset_variables:
357 		unset_variable
358 	|	unset_variables ',' unset_variable
359 ;
360 
361 unset_variable:
362 		variable	{ zend_do_end_variable_parse(&$1, BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1 TSRMLS_CC); }
363 ;
364 
365 function_declaration_statement:
366 		unticked_function_declaration_statement	{ DO_TICKS(); }
367 ;
368 
369 class_declaration_statement:
370 		unticked_class_declaration_statement	{ DO_TICKS(); }
371 ;
372 
373 is_reference:
374 		/* empty */	{ $$.op_type = ZEND_RETURN_VAL; }
375 	|	'&'			{ $$.op_type = ZEND_RETURN_REF; }
376 ;
377 
378 
379 unticked_function_declaration_statement:
380 		function is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$3, 0, $2.op_type, NULL TSRMLS_CC); }
381 		'(' parameter_list ')'
382 		'{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
383 ;
384 
385 unticked_class_declaration_statement:
386 		class_entry_type T_STRING extends_from
387 			{ zend_do_begin_class_declaration(&$1, &$2, &$3 TSRMLS_CC); }
388 			implements_list
389 			'{'
390 				class_statement_list
391 			'}' { zend_do_end_class_declaration(&$1, &$3 TSRMLS_CC); }
392 	|	interface_entry T_STRING
393 			{ zend_do_begin_class_declaration(&$1, &$2, NULL TSRMLS_CC); }
394 			interface_extends_list
395 			'{'
396 				class_statement_list
397 			'}' { zend_do_end_class_declaration(&$1, NULL TSRMLS_CC); }
398 ;
399 
400 
401 class_entry_type:
402 		T_CLASS			{ $$.u.op.opline_num = CG(zend_lineno); $$.EA = 0; }
403 	|	T_ABSTRACT T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; }
404 	|	T_TRAIT { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_TRAIT; }
405 	|	T_FINAL T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_FINAL_CLASS; }
406 ;
407 
408 extends_from:
409 		/* empty */					{ $$.op_type = IS_UNUSED; }
410 	|	T_EXTENDS fully_qualified_class_name	{ zend_do_fetch_class(&$$, &$2 TSRMLS_CC); }
411 ;
412 
413 interface_entry:
414 	T_INTERFACE		{ $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_INTERFACE; }
415 ;
416 
417 interface_extends_list:
418 		/* empty */
419 	|	T_EXTENDS interface_list
420 ;
421 
422 implements_list:
423 		/* empty */
424 	|	T_IMPLEMENTS interface_list
425 ;
426 
427 interface_list:
428 		fully_qualified_class_name			{ zend_do_implements_interface(&$1 TSRMLS_CC); }
429 	|	interface_list ',' fully_qualified_class_name { zend_do_implements_interface(&$3 TSRMLS_CC); }
430 ;
431 
432 foreach_optional_arg:
433 		/* empty */						{ $$.op_type = IS_UNUSED; }
434 	|	T_DOUBLE_ARROW foreach_variable	{ $$ = $2; }
435 ;
436 
437 foreach_variable:
438 		variable			{ zend_check_writable_variable(&$1); $$ = $1; }
439 	|	'&' variable		{ zend_check_writable_variable(&$2); $$ = $2;  $$.EA |= ZEND_PARSED_REFERENCE_VARIABLE; }
440 	|	T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' { $$ = $1; $$.EA = ZEND_PARSED_LIST_EXPR; }
441 ;
442 
443 for_statement:
444 		statement
445 	|	':' inner_statement_list T_ENDFOR ';'
446 ;
447 
448 
449 foreach_statement:
450 		statement
451 	|	':' inner_statement_list T_ENDFOREACH ';'
452 ;
453 
454 
455 declare_statement:
456 		statement
457 	|	':' inner_statement_list T_ENDDECLARE ';'
458 ;
459 
460 
461 declare_list:
462 		T_STRING '=' static_scalar					{ zend_do_declare_stmt(&$1, &$3 TSRMLS_CC); }
463 	|	declare_list ',' T_STRING '=' static_scalar	{ zend_do_declare_stmt(&$3, &$5 TSRMLS_CC); }
464 ;
465 
466 
467 switch_case_list:
468 		'{' case_list '}'					{ $$ = $2; }
469 	|	'{' ';' case_list '}'				{ $$ = $3; }
470 	|	':' case_list T_ENDSWITCH ';'		{ $$ = $2; }
471 	|	':' ';' case_list T_ENDSWITCH ';'	{ $$ = $3; }
472 ;
473 
474 
475 case_list:
476 		/* empty */	{ $$.op_type = IS_UNUSED; }
477 	|	case_list T_CASE expr case_separator { zend_do_extended_info(TSRMLS_C);  zend_do_case_before_statement(&$1, &$2, &$3 TSRMLS_CC); } inner_statement_list { zend_do_case_after_statement(&$$, &$2 TSRMLS_CC); $$.op_type = IS_CONST; }
478 	|	case_list T_DEFAULT case_separator { zend_do_extended_info(TSRMLS_C);  zend_do_default_before_statement(&$1, &$2 TSRMLS_CC); } inner_statement_list { zend_do_case_after_statement(&$$, &$2 TSRMLS_CC); $$.op_type = IS_CONST; }
479 ;
480 
481 
482 case_separator:
483 		':'
484 	|	';'
485 ;
486 
487 
488 while_statement:
489 		statement
490 	|	':' inner_statement_list T_ENDWHILE ';'
491 ;
492 
493 
494 
495 elseif_list:
496 		/* empty */
497 	|	elseif_list T_ELSEIF parenthesis_expr { zend_do_if_cond(&$3, &$2 TSRMLS_CC); } statement { zend_do_if_after_statement(&$2, 0 TSRMLS_CC); }
498 ;
499 
500 
501 new_elseif_list:
502 		/* empty */
503 	|	new_elseif_list T_ELSEIF parenthesis_expr ':' { zend_do_if_cond(&$3, &$2 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$2, 0 TSRMLS_CC); }
504 ;
505 
506 
507 else_single:
508 		/* empty */
509 	|	T_ELSE statement
510 ;
511 
512 
513 new_else_single:
514 		/* empty */
515 	|	T_ELSE ':' inner_statement_list
516 ;
517 
518 
519 parameter_list:
520 		non_empty_parameter_list
521 	|	/* empty */
522 ;
523 
524 
525 non_empty_parameter_list:
526 		optional_class_type T_VARIABLE				{ $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV, &$2, &$$, NULL, &$1, 0 TSRMLS_CC); }
527 	|	optional_class_type '&' T_VARIABLE			{ $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV, &$3, &$$, NULL, &$1, 1 TSRMLS_CC); }
528 	|	optional_class_type '&' T_VARIABLE '=' static_scalar			{ $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV_INIT, &$3, &$$, &$5, &$1, 1 TSRMLS_CC); }
529 	|	optional_class_type T_VARIABLE '=' static_scalar				{ $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV_INIT, &$2, &$$, &$4, &$1, 0 TSRMLS_CC); }
530 	|	non_empty_parameter_list ',' optional_class_type T_VARIABLE 	{ $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV, &$4, &$$, NULL, &$3, 0 TSRMLS_CC); }
531 	|	non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE	{ $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV, &$5, &$$, NULL, &$3, 1 TSRMLS_CC); }
532 	|	non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE	 '=' static_scalar { $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV_INIT, &$5, &$$, &$7, &$3, 1 TSRMLS_CC); }
533 	|	non_empty_parameter_list ',' optional_class_type T_VARIABLE '=' static_scalar 	{ $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV_INIT, &$4, &$$, &$6, &$3, 0 TSRMLS_CC); }
534 ;
535 
536 
537 optional_class_type:
538 		/* empty */					{ $$.op_type = IS_UNUSED; }
539 	|	T_ARRAY						{ $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_ARRAY; }
540 	|	T_CALLABLE					{ $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_CALLABLE; }
541 	|	fully_qualified_class_name			{ $$ = $1; }
542 ;
543 
544 
545 function_call_parameter_list:
546 		'(' ')'	{ Z_LVAL($$.u.constant) = 0; }
547 	|	'(' non_empty_function_call_parameter_list ')'	{ $$ = $2; }
548 	|	'(' yield_expr ')'	{ Z_LVAL($$.u.constant) = 1; zend_do_pass_param(&$2, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); }
549 ;
550 
551 
552 non_empty_function_call_parameter_list:
553 		expr_without_variable	{ Z_LVAL($$.u.constant) = 1;  zend_do_pass_param(&$1, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); }
554 	|	variable				{ Z_LVAL($$.u.constant) = 1;  zend_do_pass_param(&$1, ZEND_SEND_VAR, Z_LVAL($$.u.constant) TSRMLS_CC); }
555 	|	'&' w_variable 				{ Z_LVAL($$.u.constant) = 1;  zend_do_pass_param(&$2, ZEND_SEND_REF, Z_LVAL($$.u.constant) TSRMLS_CC); }
556 	|	non_empty_function_call_parameter_list ',' expr_without_variable	{ Z_LVAL($$.u.constant)=Z_LVAL($1.u.constant)+1;  zend_do_pass_param(&$3, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); }
557 	|	non_empty_function_call_parameter_list ',' variable					{ Z_LVAL($$.u.constant)=Z_LVAL($1.u.constant)+1;  zend_do_pass_param(&$3, ZEND_SEND_VAR, Z_LVAL($$.u.constant) TSRMLS_CC); }
558 	|	non_empty_function_call_parameter_list ',' '&' w_variable			{ Z_LVAL($$.u.constant)=Z_LVAL($1.u.constant)+1;  zend_do_pass_param(&$4, ZEND_SEND_REF, Z_LVAL($$.u.constant) TSRMLS_CC); }
559 ;
560 
561 global_var_list:
562 		global_var_list ',' global_var	{ zend_do_fetch_global_variable(&$3, NULL, ZEND_FETCH_GLOBAL_LOCK TSRMLS_CC); }
563 	|	global_var						{ zend_do_fetch_global_variable(&$1, NULL, ZEND_FETCH_GLOBAL_LOCK TSRMLS_CC); }
564 ;
565 
566 
567 global_var:
568 		T_VARIABLE			{ $$ = $1; }
569 	|	'$' r_variable		{ $$ = $2; }
570 	|	'$' '{' expr '}'	{ $$ = $3; }
571 ;
572 
573 
574 static_var_list:
575 		static_var_list ',' T_VARIABLE { zend_do_fetch_static_variable(&$3, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
576 	|	static_var_list ',' T_VARIABLE '=' static_scalar { zend_do_fetch_static_variable(&$3, &$5, ZEND_FETCH_STATIC TSRMLS_CC); }
577 	|	T_VARIABLE  { zend_do_fetch_static_variable(&$1, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
578 	|	T_VARIABLE '=' static_scalar { zend_do_fetch_static_variable(&$1, &$3, ZEND_FETCH_STATIC TSRMLS_CC); }
579 
580 ;
581 
582 
583 class_statement_list:
584 		class_statement_list class_statement
585 	|	/* empty */
586 ;
587 
588 
589 class_statement:
590 		variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';'
591 	|	class_constant_declaration ';'
592 	|	trait_use_statement
593 	|	method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); }
594 		'(' parameter_list ')'
595 		method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); }
596 ;
597 
598 trait_use_statement:
599 		T_USE trait_list trait_adaptations
600 ;
601 
602 trait_list:
603 		fully_qualified_class_name						{ zend_do_use_trait(&$1 TSRMLS_CC); }
604 	|	trait_list ',' fully_qualified_class_name		{ zend_do_use_trait(&$3 TSRMLS_CC); }
605 ;
606 
607 trait_adaptations:
608 		';'
609 	|	'{' trait_adaptation_list '}'
610 ;
611 
612 trait_adaptation_list:
613 		/* empty */
614 	|	non_empty_trait_adaptation_list
615 ;
616 
617 non_empty_trait_adaptation_list:
618 		trait_adaptation_statement
619 	|	non_empty_trait_adaptation_list trait_adaptation_statement
620 ;
621 
622 trait_adaptation_statement:
623 		trait_precedence ';'
624 	|	trait_alias ';'
625 ;
626 
627 trait_precedence:
628 	trait_method_reference_fully_qualified T_INSTEADOF trait_reference_list	{ zend_add_trait_precedence(&$1, &$3 TSRMLS_CC); }
629 ;
630 
631 trait_reference_list:
632 		fully_qualified_class_name									{ zend_resolve_class_name(&$1, ZEND_FETCH_CLASS_GLOBAL, 1 TSRMLS_CC); zend_init_list(&$$.u.op.ptr, Z_STRVAL($1.u.constant) TSRMLS_CC); }
633 	|	trait_reference_list ',' fully_qualified_class_name			{ zend_resolve_class_name(&$3, ZEND_FETCH_CLASS_GLOBAL, 1 TSRMLS_CC); zend_add_to_list(&$1.u.op.ptr, Z_STRVAL($3.u.constant) TSRMLS_CC); $$ = $1; }
634 ;
635 
636 trait_method_reference:
637 		T_STRING													{ zend_prepare_reference(&$$, NULL, &$1 TSRMLS_CC); }
638 	|	trait_method_reference_fully_qualified						{ $$ = $1; }
639 ;
640 
641 trait_method_reference_fully_qualified:
642 	fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING		{ zend_prepare_reference(&$$, &$1, &$3 TSRMLS_CC); }
643 ;
644 
645 trait_alias:
646 		trait_method_reference T_AS trait_modifiers T_STRING		{ zend_add_trait_alias(&$1, &$3, &$4 TSRMLS_CC); }
647 	|	trait_method_reference T_AS member_modifier					{ zend_add_trait_alias(&$1, &$3, NULL TSRMLS_CC); }
648 ;
649 
650 trait_modifiers:
651 		/* empty */					{ Z_LVAL($$.u.constant) = 0x0; } /* No change of methods visibility */
652 	|	member_modifier	{ $$ = $1; } /* REM: Keep in mind, there are not only visibility modifiers */
653 ;
654 
655 method_body:
656 		';' /* abstract method */		{ Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; }
657 	|	'{' inner_statement_list '}'	{ Z_LVAL($$.u.constant) = 0;	}
658 ;
659 
660 variable_modifiers:
661 		non_empty_member_modifiers		{ $$ = $1; }
662 	|	T_VAR							{ Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
663 ;
664 
665 method_modifiers:
666 		/* empty */							{ Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
667 	|	non_empty_member_modifiers			{ $$ = $1;  if (!(Z_LVAL($$.u.constant) & ZEND_ACC_PPP_MASK)) { Z_LVAL($$.u.constant) |= ZEND_ACC_PUBLIC; } }
668 ;
669 
670 non_empty_member_modifiers:
671 		member_modifier						{ $$ = $1; }
672 	|	non_empty_member_modifiers member_modifier	{ Z_LVAL($$.u.constant) = zend_do_verify_access_types(&$1, &$2); }
673 ;
674 
675 member_modifier:
676 		T_PUBLIC				{ Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
677 	|	T_PROTECTED				{ Z_LVAL($$.u.constant) = ZEND_ACC_PROTECTED; }
678 	|	T_PRIVATE				{ Z_LVAL($$.u.constant) = ZEND_ACC_PRIVATE; }
679 	|	T_STATIC				{ Z_LVAL($$.u.constant) = ZEND_ACC_STATIC; }
680 	|	T_ABSTRACT				{ Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; }
681 	|	T_FINAL					{ Z_LVAL($$.u.constant) = ZEND_ACC_FINAL; }
682 ;
683 
684 class_variable_declaration:
685 		class_variable_declaration ',' T_VARIABLE					{ zend_do_declare_property(&$3, NULL, CG(access_type) TSRMLS_CC); }
686 	|	class_variable_declaration ',' T_VARIABLE '=' static_scalar	{ zend_do_declare_property(&$3, &$5, CG(access_type) TSRMLS_CC); }
687 	|	T_VARIABLE						{ zend_do_declare_property(&$1, NULL, CG(access_type) TSRMLS_CC); }
688 	|	T_VARIABLE '=' static_scalar	{ zend_do_declare_property(&$1, &$3, CG(access_type) TSRMLS_CC); }
689 ;
690 
691 class_constant_declaration:
692 		class_constant_declaration ',' T_STRING '=' static_scalar	{ zend_do_declare_class_constant(&$3, &$5 TSRMLS_CC); }
693 	|	T_CONST T_STRING '=' static_scalar	{ zend_do_declare_class_constant(&$2, &$4 TSRMLS_CC); }
694 ;
695 
696 echo_expr_list:
697 		echo_expr_list ',' expr { zend_do_echo(&$3 TSRMLS_CC); }
698 	|	expr					{ zend_do_echo(&$1 TSRMLS_CC); }
699 ;
700 
701 
702 for_expr:
703 		/* empty */			{ $$.op_type = IS_CONST;  Z_TYPE($$.u.constant) = IS_BOOL;  Z_LVAL($$.u.constant) = 1; }
704 	|	non_empty_for_expr	{ $$ = $1; }
705 ;
706 
707 non_empty_for_expr:
708 		non_empty_for_expr ','	{ zend_do_free(&$1 TSRMLS_CC); } expr { $$ = $4; }
709 	|	expr					{ $$ = $1; }
710 ;
711 
712 chaining_method_or_property:
713 		chaining_method_or_property variable_property 	{ $$.EA = $2.EA; }
714 	|	variable_property 								{ $$.EA = $1.EA; }
715 ;
716 
717 chaining_dereference:
718 		chaining_dereference '[' dim_offset ']'	{ fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
719 	|	'[' dim_offset ']'		{ zend_do_pop_object(&$1 TSRMLS_CC); fetch_array_dim(&$$, &$1, &$2 TSRMLS_CC); }
720 ;
721 
722 chaining_instance_call:
723 		chaining_dereference 		{ zend_do_push_object(&$1 TSRMLS_CC); } chaining_method_or_property { $$ = $3; }
724 	|	chaining_dereference 		{ zend_do_push_object(&$1 TSRMLS_CC); $$ = $1; }
725 	|	chaining_method_or_property { $$ = $1; }
726 ;
727 
728 instance_call:
729 		/* empty */ 		{ $$ = $0; }
730 	|	{ zend_do_push_object(&$0 TSRMLS_CC); zend_do_begin_variable_parse(TSRMLS_C); }
731 		chaining_instance_call	{ zend_do_pop_object(&$$ TSRMLS_CC); zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC); }
732 ;
733 
734 new_expr:
735 		T_NEW class_name_reference { zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$1, &$2 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$$, &$1, &$4 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
736 ;
737 
738 expr_without_variable:
739 		T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 TSRMLS_CC); }
740 	|	variable '=' expr		{ zend_check_writable_variable(&$1); zend_do_assign(&$$, &$1, &$3 TSRMLS_CC); }
741 	|	variable '=' '&' variable { zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$4, BP_VAR_W, 1 TSRMLS_CC); zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$4 TSRMLS_CC); }
742 	|	variable '=' '&' T_NEW class_name_reference { zend_error(E_DEPRECATED, "Assigning the return value of new by reference is deprecated");  zend_check_writable_variable(&$1); zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$4, &$5 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$3, &$4, &$7 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); $3.EA = ZEND_PARSED_NEW; zend_do_assign_ref(&$$, &$1, &$3 TSRMLS_CC); }
743 	|	T_CLONE expr { zend_do_clone(&$$, &$2 TSRMLS_CC); }
744 	|	variable T_PLUS_EQUAL expr 	{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_ADD, &$$, &$1, &$3 TSRMLS_CC); }
745 	|	variable T_MINUS_EQUAL expr	{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SUB, &$$, &$1, &$3 TSRMLS_CC); }
746 	|	variable T_MUL_EQUAL expr		{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_MUL, &$$, &$1, &$3 TSRMLS_CC); }
747 	|	variable T_DIV_EQUAL expr		{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_DIV, &$$, &$1, &$3 TSRMLS_CC); }
748 	|	variable T_CONCAT_EQUAL expr	{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_CONCAT, &$$, &$1, &$3 TSRMLS_CC); }
749 	|	variable T_MOD_EQUAL expr		{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_MOD, &$$, &$1, &$3 TSRMLS_CC); }
750 	|	variable T_AND_EQUAL expr		{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_AND, &$$, &$1, &$3 TSRMLS_CC); }
751 	|	variable T_OR_EQUAL expr 		{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_OR, &$$, &$1, &$3 TSRMLS_CC); }
752 	|	variable T_XOR_EQUAL expr 		{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_BW_XOR, &$$, &$1, &$3 TSRMLS_CC); }
753 	|	variable T_SL_EQUAL expr	{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SL, &$$, &$1, &$3 TSRMLS_CC); }
754 	|	variable T_SR_EQUAL expr	{ zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SR, &$$, &$1, &$3 TSRMLS_CC); }
755 	|	rw_variable T_INC { zend_do_post_incdec(&$$, &$1, ZEND_POST_INC TSRMLS_CC); }
756 	|	T_INC rw_variable { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_INC TSRMLS_CC); }
757 	|	rw_variable T_DEC { zend_do_post_incdec(&$$, &$1, ZEND_POST_DEC TSRMLS_CC); }
758 	|	T_DEC rw_variable { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_DEC TSRMLS_CC); }
759 	|	expr T_BOOLEAN_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
760 	|	expr T_BOOLEAN_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
761 	|	expr T_LOGICAL_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
762 	|	expr T_LOGICAL_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
763 	|	expr T_LOGICAL_XOR expr { zend_do_binary_op(ZEND_BOOL_XOR, &$$, &$1, &$3 TSRMLS_CC); }
764 	|	expr '|' expr	{ zend_do_binary_op(ZEND_BW_OR, &$$, &$1, &$3 TSRMLS_CC); }
765 	|	expr '&' expr	{ zend_do_binary_op(ZEND_BW_AND, &$$, &$1, &$3 TSRMLS_CC); }
766 	|	expr '^' expr	{ zend_do_binary_op(ZEND_BW_XOR, &$$, &$1, &$3 TSRMLS_CC); }
767 	|	expr '.' expr 	{ zend_do_binary_op(ZEND_CONCAT, &$$, &$1, &$3 TSRMLS_CC); }
768 	|	expr '+' expr 	{ zend_do_binary_op(ZEND_ADD, &$$, &$1, &$3 TSRMLS_CC); }
769 	|	expr '-' expr 	{ zend_do_binary_op(ZEND_SUB, &$$, &$1, &$3 TSRMLS_CC); }
770 	|	expr '*' expr	{ zend_do_binary_op(ZEND_MUL, &$$, &$1, &$3 TSRMLS_CC); }
771 	|	expr '/' expr	{ zend_do_binary_op(ZEND_DIV, &$$, &$1, &$3 TSRMLS_CC); }
772 	|	expr '%' expr 	{ zend_do_binary_op(ZEND_MOD, &$$, &$1, &$3 TSRMLS_CC); }
773 	| 	expr T_SL expr	{ zend_do_binary_op(ZEND_SL, &$$, &$1, &$3 TSRMLS_CC); }
774 	|	expr T_SR expr	{ zend_do_binary_op(ZEND_SR, &$$, &$1, &$3 TSRMLS_CC); }
775 	|	'+' expr %prec T_INC { ZVAL_LONG(&$1.u.constant, 0); if ($2.op_type == IS_CONST) { add_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; } else { $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); zend_do_binary_op(ZEND_ADD, &$$, &$1, &$2 TSRMLS_CC); } }
776 	|	'-' expr %prec T_INC { ZVAL_LONG(&$1.u.constant, 0); if ($2.op_type == IS_CONST) { sub_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; } else { $1.op_type = IS_CONST; INIT_PZVAL(&$1.u.constant); zend_do_binary_op(ZEND_SUB, &$$, &$1, &$2 TSRMLS_CC); } }
777 	|	'!' expr { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$2 TSRMLS_CC); }
778 	|	'~' expr { zend_do_unary_op(ZEND_BW_NOT, &$$, &$2 TSRMLS_CC); }
779 	|	expr T_IS_IDENTICAL expr		{ zend_do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
780 	|	expr T_IS_NOT_IDENTICAL expr	{ zend_do_binary_op(ZEND_IS_NOT_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
781 	|	expr T_IS_EQUAL expr			{ zend_do_binary_op(ZEND_IS_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
782 	|	expr T_IS_NOT_EQUAL expr 		{ zend_do_binary_op(ZEND_IS_NOT_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
783 	|	expr '<' expr 					{ zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$1, &$3 TSRMLS_CC); }
784 	|	expr T_IS_SMALLER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
785 	|	expr '>' expr 					{ zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 TSRMLS_CC); }
786 	|	expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); }
787 	|	expr T_INSTANCEOF class_name_reference { zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); }
788 	|	parenthesis_expr 	{ $$ = $1; }
789 	|	new_expr		{ $$ = $1; }
790 	|	'(' new_expr ')' { $$ = $2; } instance_call { $$ = $5; }
791 	|	expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
792 		expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
793 		expr	 { zend_do_qm_false(&$$, &$7, &$2, &$5 TSRMLS_CC); }
794 	|	expr '?' ':' { zend_do_jmp_set(&$1, &$2, &$3 TSRMLS_CC); }
795 		expr     { zend_do_jmp_set_else(&$$, &$5, &$2, &$3 TSRMLS_CC); }
796 	|	internal_functions_in_yacc { $$ = $1; }
797 	|	T_INT_CAST expr 	{ zend_do_cast(&$$, &$2, IS_LONG TSRMLS_CC); }
798 	|	T_DOUBLE_CAST expr 	{ zend_do_cast(&$$, &$2, IS_DOUBLE TSRMLS_CC); }
799 	|	T_STRING_CAST expr	{ zend_do_cast(&$$, &$2, IS_STRING TSRMLS_CC); }
800 	|	T_ARRAY_CAST expr 	{ zend_do_cast(&$$, &$2, IS_ARRAY TSRMLS_CC); }
801 	|	T_OBJECT_CAST expr 	{ zend_do_cast(&$$, &$2, IS_OBJECT TSRMLS_CC); }
802 	|	T_BOOL_CAST expr	{ zend_do_cast(&$$, &$2, IS_BOOL TSRMLS_CC); }
803 	|	T_UNSET_CAST expr	{ zend_do_cast(&$$, &$2, IS_NULL TSRMLS_CC); }
804 	|	T_EXIT exit_expr	{ zend_do_exit(&$$, &$2 TSRMLS_CC); }
805 	|	'@' { zend_do_begin_silence(&$1 TSRMLS_CC); } expr { zend_do_end_silence(&$1 TSRMLS_CC); $$ = $3; }
806 	|	scalar				{ $$ = $1; }
807 	|	combined_scalar_offset { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); }
808 	|	combined_scalar { $$ = $1; }
809 	|	'`' backticks_expr '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); }
810 	|	T_PRINT expr  { zend_do_print(&$$, &$2 TSRMLS_CC); }
811 	|	T_YIELD { zend_do_yield(&$$, NULL, NULL, 0 TSRMLS_CC); }
812 	|	function is_reference { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, 0 TSRMLS_CC); }
813 		'(' parameter_list ')' lexical_vars
814 		'{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $3; }
815 	|	T_STATIC function is_reference { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); }
816 		'(' parameter_list ')' lexical_vars
817 		'{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $4; }
818 ;
819 
820 yield_expr:
821 		T_YIELD expr_without_variable { zend_do_yield(&$$, &$2, NULL, 0 TSRMLS_CC); }
822 	|	T_YIELD variable { zend_do_yield(&$$, &$2, NULL, 1 TSRMLS_CC); }
823 	|	T_YIELD expr T_DOUBLE_ARROW expr_without_variable { zend_do_yield(&$$, &$4, &$2, 0 TSRMLS_CC); }
824 	|	T_YIELD expr T_DOUBLE_ARROW variable { zend_do_yield(&$$, &$4, &$2, 1 TSRMLS_CC); }
825 ;
826 
827 combined_scalar_offset:
828 	  combined_scalar '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
829 	| combined_scalar_offset '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
830     | T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' { $1.EA = 0; zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
831 
832 combined_scalar:
833       T_ARRAY '(' array_pair_list ')' { $$ = $3; }
834     | '[' array_pair_list ']' { $$ = $2; }
835 
836 function:
837 	T_FUNCTION { $$.u.op.opline_num = CG(zend_lineno); }
838 ;
839 
840 lexical_vars:
841 		/* empty */
842 	|	T_USE '(' lexical_var_list ')'
843 ;
844 
845 lexical_var_list:
846 		lexical_var_list ',' T_VARIABLE			{ zend_do_fetch_lexical_variable(&$3, 0 TSRMLS_CC); }
847 	|	lexical_var_list ',' '&' T_VARIABLE		{ zend_do_fetch_lexical_variable(&$4, 1 TSRMLS_CC); }
848 	|	T_VARIABLE								{ zend_do_fetch_lexical_variable(&$1, 0 TSRMLS_CC); }
849 	|	'&' T_VARIABLE							{ zend_do_fetch_lexical_variable(&$2, 1 TSRMLS_CC); }
850 ;
851 
852 function_call:
853 		namespace_name { $$.u.op.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); }
854 		function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$3, 0, $2.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
855 	|	T_NAMESPACE T_NS_SEPARATOR namespace_name { $1.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$1.u.constant);  zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC); $$.u.op.opline_num = zend_do_begin_function_call(&$1, 0 TSRMLS_CC); }
856 		function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$5, 0, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
857 	|	T_NS_SEPARATOR namespace_name { $$.u.op.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
858 		function_call_parameter_list { zend_do_end_function_call(&$2, &$$, &$4, 0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
859 	|	class_name T_PAAMAYIM_NEKUDOTAYIM variable_name { $$.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
860 		function_call_parameter_list { zend_do_end_function_call($4.u.op.opline_num?NULL:&$3, &$$, &$5, $4.u.op.opline_num, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
861 	|	class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
862 		function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
863 	|	variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
864 		function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
865 	|	variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
866 		function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
867 	|	variable_without_objects { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call(&$1, 0 TSRMLS_CC); }
868 		function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$3, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
869 ;
870 
871 class_name:
872 		T_STATIC { $$.op_type = IS_CONST; ZVAL_STRINGL(&$$.u.constant, "static", sizeof("static")-1, 1);}
873 	|	namespace_name { $$ = $1; }
874 	|	T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant);  zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); }
875 	|	T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); $$ = $2; }
876 ;
877 
878 fully_qualified_class_name:
879 		namespace_name { $$ = $1; }
880 	|	T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant);  zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); }
881 	|	T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); $$ = $2; }
882 ;
883 
884 
885 
886 class_name_reference:
887 		class_name						{ zend_do_fetch_class(&$$, &$1 TSRMLS_CC); }
888 	|	dynamic_class_name_reference	{ zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class(&$$, &$1 TSRMLS_CC); }
889 ;
890 
891 
892 dynamic_class_name_reference:
893 		base_variable T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
894 			object_property { zend_do_push_object(&$4 TSRMLS_CC); } dynamic_class_name_variable_properties
895 			{ zend_do_pop_object(&$$ TSRMLS_CC); $$.EA = ZEND_PARSED_MEMBER; }
896 	|	base_variable { $$ = $1; }
897 ;
898 
899 
900 dynamic_class_name_variable_properties:
901 		dynamic_class_name_variable_properties dynamic_class_name_variable_property
902 	|	/* empty */
903 ;
904 
905 
906 dynamic_class_name_variable_property:
907 		T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); }
908 ;
909 
910 exit_expr:
911 		/* empty */	{ memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
912 	|	'(' ')'		{ memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
913 	|	parenthesis_expr	{ $$ = $1; }
914 ;
915 
916 backticks_expr:
917 		/* empty */	{ ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; }
918 	|	T_ENCAPSED_AND_WHITESPACE	{ $$ = $1; }
919 	|	encaps_list	{ $$ = $1; }
920 ;
921 
922 
923 ctor_arguments:
924 		/* empty */	{ Z_LVAL($$.u.constant) = 0; }
925 	|	function_call_parameter_list 	{ $$ = $1; }
926 ;
927 
928 
929 common_scalar:
930 		T_LNUMBER 					{ $$ = $1; }
931 	|	T_DNUMBER 					{ $$ = $1; }
932 	|	T_CONSTANT_ENCAPSED_STRING	{ $$ = $1; }
933 	|	T_LINE 						{ $$ = $1; }
934 	|	T_FILE 						{ $$ = $1; }
935 	|	T_DIR   					{ $$ = $1; }
936 	|	T_TRAIT_C					{ $$ = $1; }
937 	|	T_METHOD_C					{ $$ = $1; }
938 	|	T_FUNC_C					{ $$ = $1; }
939 	|	T_NS_C						{ $$ = $1; }
940 	|	T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2; }
941 	|	T_START_HEREDOC T_END_HEREDOC { ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; }
942 ;
943 
944 
945 static_scalar: /* compile-time evaluated scalars */
946 		common_scalar		{ $$ = $1; }
947 	|	static_class_name_scalar	{ $$ = $1; }
948 	|	namespace_name 		{ zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT, 1 TSRMLS_CC); }
949 	|	T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant);  zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_CT, 0 TSRMLS_CC); }
950 	|	T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_CT, 0 TSRMLS_CC); }
951 	|	'+' static_scalar { ZVAL_LONG(&$1.u.constant, 0); add_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
952 	|	'-' static_scalar { ZVAL_LONG(&$1.u.constant, 0); sub_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
953 	|	T_ARRAY '(' static_array_pair_list ')' { $$ = $3; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
954 	|	'[' static_array_pair_list ']' { $$ = $2; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
955 	|	static_class_constant { $$ = $1; }
956 	|	T_CLASS_C			{ $$ = $1; }
957 ;
958 
959 static_class_constant:
960 		class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_CT, 0 TSRMLS_CC); }
961 ;
962 
963 scalar:
964 		T_STRING_VARNAME		{ $$ = $1; }
965 	|	class_name_scalar	{ $$ = $1; }
966 	|	class_constant		{ $$ = $1; }
967 	|	namespace_name	{ zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC); }
968 	|	T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant);  zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); $3 = $$; zend_do_fetch_constant(&$$, NULL, &$3, ZEND_RT, 0 TSRMLS_CC); }
969 	|	T_NS_SEPARATOR namespace_name { char *tmp = estrndup(Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); memcpy(&(tmp[1]), Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); tmp[0] = '\\'; efree(Z_STRVAL($2.u.constant)); Z_STRVAL($2.u.constant) = tmp; ++Z_STRLEN($2.u.constant); zend_do_fetch_constant(&$$, NULL, &$2, ZEND_RT, 0 TSRMLS_CC); }
970 	|	common_scalar			{ $$ = $1; }
971 	|	'"' encaps_list '"' 	{ $$ = $2; }
972 	|	T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; }
973 	|	T_CLASS_C				{ if (Z_TYPE($1.u.constant) == IS_CONSTANT) {zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC);} else {$$ = $1;} }
974 ;
975 
976 
977 static_array_pair_list:
978 		/* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); }
979 	|	non_empty_static_array_pair_list possible_comma	{ $$ = $1; }
980 ;
981 
982 possible_comma:
983 		/* empty */
984 	|	','
985 ;
986 
987 non_empty_static_array_pair_list:
988 		non_empty_static_array_pair_list ',' static_scalar T_DOUBLE_ARROW static_scalar	{ zend_do_add_static_array_element(&$$, &$3, &$5); }
989 	|	non_empty_static_array_pair_list ',' static_scalar { zend_do_add_static_array_element(&$$, NULL, &$3); }
990 	|	static_scalar T_DOUBLE_ARROW static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, &$1, &$3); }
991 	|	static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, NULL, &$1); }
992 ;
993 
994 expr:
995 		r_variable					{ $$ = $1; }
996 	|	expr_without_variable		{ $$ = $1; }
997 ;
998 
999 parenthesis_expr:
1000 		'(' expr ')'		{ $$ = $2; }
1001 	|	'(' yield_expr ')'	{ $$ = $2; }
1002 ;
1003 
1004 
1005 r_variable:
1006 	variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$ = $1; }
1007 ;
1008 
1009 
1010 w_variable:
1011 	variable	{ zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); $$ = $1;
1012 				  zend_check_writable_variable(&$1); }
1013 ;
1014 
1015 rw_variable:
1016 	variable	{ zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); $$ = $1;
1017 				  zend_check_writable_variable(&$1); }
1018 ;
1019 
1020 variable:
1021 		base_variable_with_function_calls T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
1022 			object_property { zend_do_push_object(&$4 TSRMLS_CC); } method_or_not variable_properties
1023 			{ zend_do_pop_object(&$$ TSRMLS_CC); $$.EA = $1.EA | ($7.EA ? $7.EA : $6.EA); }
1024 	|	base_variable_with_function_calls { $$ = $1; }
1025 ;
1026 
1027 variable_properties:
1028 		variable_properties variable_property { $$.EA = $2.EA; }
1029 	|	/* empty */ { $$.EA = 0; }
1030 ;
1031 
1032 
1033 variable_property:
1034 		T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); } method_or_not { $$.EA = $4.EA; }
1035 ;
1036 
1037 array_method_dereference:
1038 		array_method_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
1039 	|	method '[' dim_offset ']' { $1.EA = ZEND_PARSED_METHOD_CALL; fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
1040 ;
1041 
1042 method:
1043 		{ zend_do_pop_object(&$$ TSRMLS_CC); zend_do_begin_method_call(&$$ TSRMLS_CC); }
1044 		function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$2, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
1045 ;
1046 
1047 method_or_not:
1048 		method						{ $$ = $1; $$.EA = ZEND_PARSED_METHOD_CALL; zend_do_push_object(&$$ TSRMLS_CC); }
1049 	|	array_method_dereference	{ $$ = $1; zend_do_push_object(&$$ TSRMLS_CC); }
1050 	|	/* empty */ { $$.EA = ZEND_PARSED_MEMBER; }
1051 ;
1052 
1053 variable_without_objects:
1054 		reference_variable { $$ = $1; }
1055 	|	simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); }
1056 ;
1057 
1058 static_member:
1059 		class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
1060 	|	variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
1061 
1062 ;
1063 
1064 variable_class_name:
1065 		reference_variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$=$1;; }
1066 ;
1067 
1068 array_function_dereference:
1069 		array_function_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
1070 	|	function_call { zend_do_begin_variable_parse(TSRMLS_C); $1.EA = ZEND_PARSED_FUNCTION_CALL; }
1071 		'[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$4 TSRMLS_CC); }
1072 ;
1073 
1074 base_variable_with_function_calls:
1075 		base_variable				{ $$ = $1; }
1076 	|	array_function_dereference	{ $$ = $1; }
1077 	|	function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; $$.EA = ZEND_PARSED_FUNCTION_CALL; }
1078 ;
1079 
1080 
1081 base_variable:
1082 		reference_variable { $$ = $1; $$.EA = ZEND_PARSED_VARIABLE; }
1083 	|	simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); $$.EA = ZEND_PARSED_VARIABLE; }
1084 	|	static_member { $$ = $1; $$.EA = ZEND_PARSED_STATIC_MEMBER; }
1085 ;
1086 
1087 reference_variable:
1088 		reference_variable '[' dim_offset ']'	{ fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
1089 	|	reference_variable '{' expr '}'		{ fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
1090 	|	compound_variable			{ zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
1091 ;
1092 
1093 
1094 compound_variable:
1095 		T_VARIABLE			{ $$ = $1; }
1096 	|	'$' '{' expr '}'	{ $$ = $3; }
1097 ;
1098 
1099 dim_offset:
1100 		/* empty */		{ $$.op_type = IS_UNUSED; }
1101 	|	expr			{ $$ = $1; }
1102 ;
1103 
1104 
1105 object_property:
1106 		object_dim_list { $$ = $1; }
1107 	|	variable_without_objects { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); } { znode tmp_znode;  zend_do_pop_object(&tmp_znode TSRMLS_CC);  zend_do_fetch_property(&$$, &tmp_znode, &$1 TSRMLS_CC);}
1108 ;
1109 
1110 object_dim_list:
1111 		object_dim_list '[' dim_offset ']'	{ fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
1112 	|	object_dim_list '{' expr '}'		{ fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
1113 	|	variable_name { znode tmp_znode;  zend_do_pop_object(&tmp_znode TSRMLS_CC);  zend_do_fetch_property(&$$, &tmp_znode, &$1 TSRMLS_CC);}
1114 ;
1115 
1116 variable_name:
1117 		T_STRING		{ $$ = $1; }
1118 	|	'{' expr '}'	{ $$ = $2; }
1119 ;
1120 
1121 simple_indirect_reference:
1122 		'$' { Z_LVAL($$.u.constant) = 1; }
1123 	|	simple_indirect_reference '$' { Z_LVAL($$.u.constant)++; }
1124 ;
1125 
1126 assignment_list:
1127 		assignment_list ',' assignment_list_element
1128 	|	assignment_list_element
1129 ;
1130 
1131 
1132 assignment_list_element:
1133 		variable								{ zend_do_add_list_element(&$1 TSRMLS_CC); }
1134 	|	T_LIST '(' { zend_do_new_list_begin(TSRMLS_C); } assignment_list ')'	{ zend_do_new_list_end(TSRMLS_C); }
1135 	|	/* empty */							{ zend_do_add_list_element(NULL TSRMLS_CC); }
1136 ;
1137 
1138 
1139 array_pair_list:
1140 		/* empty */ { zend_do_init_array(&$$, NULL, NULL, 0 TSRMLS_CC); }
1141 	|	non_empty_array_pair_list possible_comma	{ $$ = $1; }
1142 ;
1143 
1144 non_empty_array_pair_list:
1145 		non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr	{ zend_do_add_array_element(&$$, &$5, &$3, 0 TSRMLS_CC); }
1146 	|	non_empty_array_pair_list ',' expr			{ zend_do_add_array_element(&$$, &$3, NULL, 0 TSRMLS_CC); }
1147 	|	expr T_DOUBLE_ARROW expr	{ zend_do_init_array(&$$, &$3, &$1, 0 TSRMLS_CC); }
1148 	|	expr 				{ zend_do_init_array(&$$, &$1, NULL, 0 TSRMLS_CC); }
1149 	|	non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_variable { zend_do_add_array_element(&$$, &$6, &$3, 1 TSRMLS_CC); }
1150 	|	non_empty_array_pair_list ',' '&' w_variable { zend_do_add_array_element(&$$, &$4, NULL, 1 TSRMLS_CC); }
1151 	|	expr T_DOUBLE_ARROW '&' w_variable	{ zend_do_init_array(&$$, &$4, &$1, 1 TSRMLS_CC); }
1152 	|	'&' w_variable 			{ zend_do_init_array(&$$, &$2, NULL, 1 TSRMLS_CC); }
1153 ;
1154 
1155 encaps_list:
1156 		encaps_list encaps_var { zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC);  zend_do_add_variable(&$$, &$1, &$2 TSRMLS_CC); }
1157 	|	encaps_list T_ENCAPSED_AND_WHITESPACE	{ zend_do_add_string(&$$, &$1, &$2 TSRMLS_CC); }
1158 	|	encaps_var { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_add_variable(&$$, NULL, &$1 TSRMLS_CC); }
1159 	|	T_ENCAPSED_AND_WHITESPACE encaps_var	{ zend_do_add_string(&$$, NULL, &$1 TSRMLS_CC); zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC); zend_do_add_variable(&$$, &$$, &$2 TSRMLS_CC); }
1160 ;
1161 
1162 
1163 
1164 encaps_var:
1165 		T_VARIABLE { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
1166 	|	T_VARIABLE '[' { zend_do_begin_variable_parse(TSRMLS_C); } encaps_var_offset ']'	{ fetch_array_begin(&$$, &$1, &$4 TSRMLS_CC); }
1167 	|	T_VARIABLE T_OBJECT_OPERATOR T_STRING { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$2, &$1, 1 TSRMLS_CC); zend_do_fetch_property(&$$, &$2, &$3 TSRMLS_CC); }
1168 	|	T_DOLLAR_OPEN_CURLY_BRACES expr '}' { zend_do_begin_variable_parse(TSRMLS_C);  fetch_simple_variable(&$$, &$2, 1 TSRMLS_CC); }
1169 	|	T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' { zend_do_begin_variable_parse(TSRMLS_C);  fetch_array_begin(&$$, &$2, &$4 TSRMLS_CC); }
1170 	|	T_CURLY_OPEN variable '}' { $$ = $2; }
1171 ;
1172 
1173 
1174 encaps_var_offset:
1175 		T_STRING		{ $$ = $1; }
1176 	|	T_NUM_STRING	{ $$ = $1; }
1177 	|	T_VARIABLE		{ fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
1178 ;
1179 
1180 
1181 internal_functions_in_yacc:
1182 		T_ISSET '(' isset_variables ')' { $$ = $3; }
1183 	|	T_EMPTY '(' variable ')'	{ zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 TSRMLS_CC); }
1184 	|	T_EMPTY '(' expr_without_variable ')' { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$3 TSRMLS_CC); }
1185 	|	T_INCLUDE expr 			{ zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 TSRMLS_CC); }
1186 	|	T_INCLUDE_ONCE expr 	{ zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 TSRMLS_CC); }
1187 	|	T_EVAL '(' expr ')' 	{ zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 TSRMLS_CC); }
1188 	|	T_REQUIRE expr			{ zend_do_include_or_eval(ZEND_REQUIRE, &$$, &$2 TSRMLS_CC); }
1189 	|	T_REQUIRE_ONCE expr		{ zend_do_include_or_eval(ZEND_REQUIRE_ONCE, &$$, &$2 TSRMLS_CC); }
1190 ;
1191 
1192 isset_variables:
1193 		isset_variable			{ $$ = $1; }
1194 	|	isset_variables ',' { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } isset_variable { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
1195 ;
1196 
1197 isset_variable:
1198 		variable				{ zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$1 TSRMLS_CC); }
1199 	|	expr_without_variable	{ zend_error(E_COMPILE_ERROR, "Cannot use isset() on the result of an expression (you can use \"null !== expression\" instead)"); }
1200 ;
1201 
1202 class_constant:
1203 		class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT, 0 TSRMLS_CC); }
1204 	|	variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT, 0 TSRMLS_CC); }
1205 ;
1206 
1207 static_class_name_scalar:
1208 	class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS { zend_do_resolve_class_name(&$$, &$1, 1 TSRMLS_CC); }
1209 ;
1210 
1211 class_name_scalar:
1212 	class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS { zend_do_resolve_class_name(&$$, &$1, 0 TSRMLS_CC); }
1213 ;
1214 
1215 %%
1216 
1217 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1218    quotes and backslashes, so that it's suitable for yyerror.  The
1219    heuristic is that double-quoting is unnecessary unless the string
1220    contains an apostrophe, a comma, or backslash (other than
1221    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1222    null, do not copy; instead, return the length of what the result
1223    would have been.  */
1224 static YYSIZE_T zend_yytnamerr(char *yyres, const char *yystr)
1225 {
1226 	if (!yyres) {
1227 		return yystrlen(yystr);
1228 	}
1229 	{
1230 		TSRMLS_FETCH();
1231 		if (CG(parse_error) == 0) {
1232 			char buffer[120];
1233 			const unsigned char *end, *str, *tok1 = NULL, *tok2 = NULL;
1234 			unsigned int len = 0, toklen = 0, yystr_len;
1235 
1236 			CG(parse_error) = 1;
1237 
1238 			if (LANG_SCNG(yy_text)[0] == 0 &&
1239 				LANG_SCNG(yy_leng) == 1 &&
1240 				memcmp(yystr, "\"end of file\"", sizeof("\"end of file\"") - 1) == 0) {
1241 				yystpcpy(yyres, "end of file");
1242 				return sizeof("end of file")-1;
1243 			}
1244 
1245 			str = LANG_SCNG(yy_text);
1246 			end = memchr(str, '\n', LANG_SCNG(yy_leng));
1247 			yystr_len = yystrlen(yystr);
1248 
1249 			if ((tok1 = memchr(yystr, '(', yystr_len)) != NULL
1250 				&& (tok2 = zend_memrchr(yystr, ')', yystr_len)) != NULL) {
1251 				toklen = (tok2 - tok1) + 1;
1252 			} else {
1253 				tok1 = tok2 = NULL;
1254 				toklen = 0;
1255 			}
1256 
1257 			if (end == NULL) {
1258 				len = LANG_SCNG(yy_leng) > 30 ? 30 : LANG_SCNG(yy_leng);
1259 			} else {
1260 				len = (end - str) > 30 ? 30 : (end - str);
1261 			}
1262 			if (toklen) {
1263 				snprintf(buffer, sizeof(buffer), "'%.*s' %.*s", len, str, toklen, tok1);
1264 			} else {
1265 				snprintf(buffer, sizeof(buffer), "'%.*s'", len, str);
1266 			}
1267 			yystpcpy(yyres, buffer);
1268 			return len + (toklen ? toklen + 1 : 0) + 2;
1269 		}
1270 	}
1271 	if (*yystr == '"') {
1272 		YYSIZE_T yyn = 0;
1273 		const char *yyp = yystr;
1274 
1275 		for (; *++yyp != '"'; ++yyn) {
1276 			yyres[yyn] = *yyp;
1277 		}
1278 		yyres[yyn] = '\0';
1279 		return yyn;
1280 	}
1281 	yystpcpy(yyres, yystr);
1282 	return strlen(yystr);
1283 }
1284 
1285 /*
1286  * Local variables:
1287  * tab-width: 4
1288  * c-basic-offset: 4
1289  * indent-tabs-mode: t
1290  * End:
1291  */
1292