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