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