1%{
2/*
3   +----------------------------------------------------------------------+
4   | Zend Engine                                                          |
5   +----------------------------------------------------------------------+
6   | Copyright (c) 1998-2013 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
39#define YYERROR_VERBOSE
40#define YYSTYPE znode
41#ifdef ZTS
42# define YYPARSE_PARAM tsrm_ls
43# define YYLEX_PARAM tsrm_ls
44#endif
45
46
47%}
48
49%pure_parser
50%expect 2
51
52%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
53%left ','
54%left T_LOGICAL_OR
55%left T_LOGICAL_XOR
56%left T_LOGICAL_AND
57%right T_PRINT
58%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
59%left '?' ':'
60%left T_BOOLEAN_OR
61%left T_BOOLEAN_AND
62%left '|'
63%left '^'
64%left '&'
65%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
66%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
67%left T_SL T_SR
68%left '+' '-' '.'
69%left '*' '/' '%'
70%right '!'
71%nonassoc T_INSTANCEOF
72%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 '@'
73%right '['
74%nonassoc T_NEW T_CLONE
75%token T_EXIT
76%token T_IF
77%left T_ELSEIF
78%left T_ELSE
79%left T_ENDIF
80%token T_LNUMBER
81%token T_DNUMBER
82%token T_STRING
83%token T_STRING_VARNAME
84%token T_VARIABLE
85%token T_NUM_STRING
86%token T_INLINE_HTML
87%token T_CHARACTER
88%token T_BAD_CHARACTER
89%token T_ENCAPSED_AND_WHITESPACE
90%token T_CONSTANT_ENCAPSED_STRING
91%token T_ECHO
92%token T_DO
93%token T_WHILE
94%token T_ENDWHILE
95%token T_FOR
96%token T_ENDFOR
97%token T_FOREACH
98%token T_ENDFOREACH
99%token T_DECLARE
100%token T_ENDDECLARE
101%token T_AS
102%token T_SWITCH
103%token T_ENDSWITCH
104%token T_CASE
105%token T_DEFAULT
106%token T_BREAK
107%token T_CONTINUE
108%token T_GOTO
109%token T_FUNCTION
110%token T_CONST
111%token T_RETURN
112%token T_TRY
113%token T_CATCH
114%token T_THROW
115%token T_USE
116%token T_GLOBAL
117%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
118%token T_VAR
119%token T_UNSET
120%token T_ISSET
121%token T_EMPTY
122%token T_HALT_COMPILER
123%token T_CLASS
124%token T_INTERFACE
125%token T_EXTENDS
126%token T_IMPLEMENTS
127%token T_OBJECT_OPERATOR
128%token T_DOUBLE_ARROW
129%token T_LIST
130%token T_ARRAY
131%token T_CLASS_C
132%token T_METHOD_C
133%token T_FUNC_C
134%token T_LINE
135%token T_FILE
136%token T_COMMENT
137%token T_DOC_COMMENT
138%token T_OPEN_TAG
139%token T_OPEN_TAG_WITH_ECHO
140%token T_CLOSE_TAG
141%token T_WHITESPACE
142%token T_START_HEREDOC
143%token T_END_HEREDOC
144%token T_DOLLAR_OPEN_CURLY_BRACES
145%token T_CURLY_OPEN
146%token T_PAAMAYIM_NEKUDOTAYIM
147%token T_NAMESPACE
148%token T_NS_C
149%token T_DIR
150%token T_NS_SEPARATOR
151
152%% /* Rules */
153
154start:
155    top_statement_list  { zend_do_end_compilation(TSRMLS_C); }
156;
157
158top_statement_list:
159        top_statement_list  { zend_do_extended_info(TSRMLS_C); } top_statement { HANDLE_INTERACTIVE(); }
160    |   /* empty */
161;
162
163namespace_name:
164        T_STRING { $$ = $1; }
165    |   namespace_name T_NS_SEPARATOR T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
166;
167
168top_statement:
169        statement                       { zend_verify_namespace(TSRMLS_C); }
170    |   function_declaration_statement  { zend_verify_namespace(TSRMLS_C); zend_do_early_binding(TSRMLS_C); }
171    |   class_declaration_statement     { zend_verify_namespace(TSRMLS_C); zend_do_early_binding(TSRMLS_C); }
172    |   T_HALT_COMPILER '(' ')' ';'     { zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; }
173    |   T_NAMESPACE namespace_name ';'  { zend_do_begin_namespace(&$2, 0 TSRMLS_CC); }
174    |   T_NAMESPACE namespace_name '{'  { zend_do_begin_namespace(&$2, 1 TSRMLS_CC); }
175        top_statement_list '}'          { zend_do_end_namespace(TSRMLS_C); }
176    |   T_NAMESPACE '{'                 { zend_do_begin_namespace(NULL, 1 TSRMLS_CC); }
177        top_statement_list '}'          { zend_do_end_namespace(TSRMLS_C); }
178    |   T_USE use_declarations ';'      { zend_verify_namespace(TSRMLS_C); }
179    |   constant_declaration ';'        { zend_verify_namespace(TSRMLS_C); }
180;
181
182use_declarations:
183        use_declarations ',' use_declaration
184    |   use_declaration
185;
186
187use_declaration:
188        namespace_name          { zend_do_use(&$1, NULL, 0 TSRMLS_CC); }
189    |   namespace_name T_AS T_STRING    { zend_do_use(&$1, &$3, 0 TSRMLS_CC); }
190    |   T_NS_SEPARATOR namespace_name { zend_do_use(&$2, NULL, 1 TSRMLS_CC); }
191    |   T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use(&$2, &$4, 1 TSRMLS_CC); }
192;
193
194constant_declaration:
195        constant_declaration ',' T_STRING '=' static_scalar { zend_do_declare_constant(&$3, &$5 TSRMLS_CC); }
196    |   T_CONST T_STRING '=' static_scalar { zend_do_declare_constant(&$2, &$4 TSRMLS_CC); }
197;
198
199inner_statement_list:
200        inner_statement_list  { zend_do_extended_info(TSRMLS_C); } inner_statement { HANDLE_INTERACTIVE(); }
201    |   /* empty */
202;
203
204
205inner_statement:
206        statement
207    |   function_declaration_statement
208    |   class_declaration_statement
209    |   T_HALT_COMPILER '(' ')' ';'   { zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope"); }
210;
211
212
213statement:
214        unticked_statement { DO_TICKS(); }
215    |   T_STRING ':' { zend_do_label(&$1 TSRMLS_CC); }
216;
217
218unticked_statement:
219        '{' inner_statement_list '}'
220    |   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); }
221    |   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); }
222    |   T_WHILE '(' { $1.u.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); }
223    |   T_DO { $1.u.opline_num = get_next_op_number(CG(active_op_array));  zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE '(' { $5.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' ';' { zend_do_do_while_end(&$1, &$5, &$7 TSRMLS_CC); }
224    |   T_FOR
225            '('
226                for_expr
227            ';' { zend_do_free(&$3 TSRMLS_CC); $4.u.opline_num = get_next_op_number(CG(active_op_array)); }
228                for_expr
229            ';' { zend_do_extended_info(TSRMLS_C); zend_do_for_cond(&$6, &$7 TSRMLS_CC); }
230                for_expr
231            ')' { zend_do_free(&$9 TSRMLS_CC); zend_do_for_before_statement(&$4, &$7 TSRMLS_CC); }
232            for_statement { zend_do_for_end(&$7 TSRMLS_CC); }
233    |   T_SWITCH '(' expr ')'   { zend_do_switch_cond(&$3 TSRMLS_CC); } switch_case_list { zend_do_switch_end(&$6 TSRMLS_CC); }
234    |   T_BREAK ';'             { zend_do_brk_cont(ZEND_BRK, NULL TSRMLS_CC); }
235    |   T_BREAK expr ';'        { zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); }
236    |   T_CONTINUE ';'          { zend_do_brk_cont(ZEND_CONT, NULL TSRMLS_CC); }
237    |   T_CONTINUE expr ';'     { zend_do_brk_cont(ZEND_CONT, &$2 TSRMLS_CC); }
238    |   T_RETURN ';'                        { zend_do_return(NULL, 0 TSRMLS_CC); }
239    |   T_RETURN expr_without_variable ';'  { zend_do_return(&$2, 0 TSRMLS_CC); }
240    |   T_RETURN variable ';'               { zend_do_return(&$2, 1 TSRMLS_CC); }
241    |   T_GLOBAL global_var_list ';'
242    |   T_STATIC static_var_list ';'
243    |   T_ECHO echo_expr_list ';'
244    |   T_INLINE_HTML           { zend_do_echo(&$1 TSRMLS_CC); }
245    |   expr ';'                { zend_do_free(&$1 TSRMLS_CC); }
246    |   T_UNSET '(' unset_variables ')' ';'
247    |   T_FOREACH '(' variable T_AS
248        { zend_do_foreach_begin(&$1, &$2, &$3, &$4, 1 TSRMLS_CC); }
249        foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
250        foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); }
251    |   T_FOREACH '(' expr_without_variable T_AS
252        { zend_do_foreach_begin(&$1, &$2, &$3, &$4, 0 TSRMLS_CC); }
253        variable foreach_optional_arg ')' { zend_check_writable_variable(&$6); zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
254        foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); }
255    |   T_DECLARE { $1.u.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); }
256    |   ';'     /* empty statement */
257    |   T_TRY { zend_do_try(&$1 TSRMLS_CC); } '{' inner_statement_list '}'
258        T_CATCH '(' { zend_initialize_try_catch_element(&$1 TSRMLS_CC); }
259        fully_qualified_class_name { zend_do_first_catch(&$7 TSRMLS_CC); }
260        T_VARIABLE ')' { zend_do_begin_catch(&$1, &$9, &$11, &$7 TSRMLS_CC); }
261        '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
262        additional_catches { zend_do_mark_last_catch(&$7, &$18 TSRMLS_CC); }
263    |   T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
264    |   T_GOTO T_STRING ';' { zend_do_goto(&$2 TSRMLS_CC); }
265;
266
267
268additional_catches:
269        non_empty_additional_catches { $$ = $1; }
270    |   /* empty */ { $$.u.opline_num = -1; }
271;
272
273non_empty_additional_catches:
274        additional_catch { $$ = $1; }
275    |   non_empty_additional_catches additional_catch { $$ = $2; }
276;
277
278
279additional_catch:
280    T_CATCH '(' fully_qualified_class_name { $$.u.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); }
281;
282
283
284unset_variables:
285        unset_variable
286    |   unset_variables ',' unset_variable
287;
288
289unset_variable:
290        variable    { zend_do_end_variable_parse(&$1, BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1 TSRMLS_CC); }
291;
292
293function_declaration_statement:
294        unticked_function_declaration_statement { DO_TICKS(); }
295;
296
297class_declaration_statement:
298        unticked_class_declaration_statement    { DO_TICKS(); }
299;
300
301
302is_reference:
303        /* empty */ { $$.op_type = ZEND_RETURN_VAL; }
304    |   '&'         { $$.op_type = ZEND_RETURN_REF; }
305;
306
307
308unticked_function_declaration_statement:
309        function is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$3, 0, $2.op_type, NULL TSRMLS_CC); }
310            '(' parameter_list ')' '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
311;
312
313unticked_class_declaration_statement:
314        class_entry_type T_STRING extends_from
315            { zend_do_begin_class_declaration(&$1, &$2, &$3 TSRMLS_CC); }
316            implements_list
317            '{'
318                class_statement_list
319            '}' { zend_do_end_class_declaration(&$1, &$3 TSRMLS_CC); }
320    |   interface_entry T_STRING
321            { zend_do_begin_class_declaration(&$1, &$2, NULL TSRMLS_CC); }
322            interface_extends_list
323            '{'
324                class_statement_list
325            '}' { zend_do_end_class_declaration(&$1, NULL TSRMLS_CC); }
326;
327
328
329class_entry_type:
330        T_CLASS         { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = 0; }
331    |   T_ABSTRACT T_CLASS { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; }
332    |   T_FINAL T_CLASS { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = ZEND_ACC_FINAL_CLASS; }
333;
334
335extends_from:
336        /* empty */                 { $$.op_type = IS_UNUSED; }
337    |   T_EXTENDS fully_qualified_class_name    { zend_do_fetch_class(&$$, &$2 TSRMLS_CC); }
338;
339
340interface_entry:
341    T_INTERFACE     { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = ZEND_ACC_INTERFACE; }
342;
343
344interface_extends_list:
345        /* empty */
346    |   T_EXTENDS interface_list
347;
348
349implements_list:
350        /* empty */
351    |   T_IMPLEMENTS interface_list
352;
353
354interface_list:
355        fully_qualified_class_name          { zend_do_implements_interface(&$1 TSRMLS_CC); }
356    |   interface_list ',' fully_qualified_class_name { zend_do_implements_interface(&$3 TSRMLS_CC); }
357;
358
359foreach_optional_arg:
360        /* empty */                     { $$.op_type = IS_UNUSED; }
361    |   T_DOUBLE_ARROW foreach_variable { $$ = $2; }
362;
363
364
365foreach_variable:
366        variable            { zend_check_writable_variable(&$1); $$ = $1; }
367    |   '&' variable        { zend_check_writable_variable(&$2); $$ = $2;  $$.u.EA.type |= ZEND_PARSED_REFERENCE_VARIABLE; }
368;
369
370for_statement:
371        statement
372    |   ':' inner_statement_list T_ENDFOR ';'
373;
374
375
376foreach_statement:
377        statement
378    |   ':' inner_statement_list T_ENDFOREACH ';'
379;
380
381
382declare_statement:
383        statement
384    |   ':' inner_statement_list T_ENDDECLARE ';'
385;
386
387
388declare_list:
389        T_STRING '=' static_scalar                  { zend_do_declare_stmt(&$1, &$3 TSRMLS_CC); }
390    |   declare_list ',' T_STRING '=' static_scalar { zend_do_declare_stmt(&$3, &$5 TSRMLS_CC); }
391;
392
393
394switch_case_list:
395        '{' case_list '}'                   { $$ = $2; }
396    |   '{' ';' case_list '}'               { $$ = $3; }
397    |   ':' case_list T_ENDSWITCH ';'       { $$ = $2; }
398    |   ':' ';' case_list T_ENDSWITCH ';'   { $$ = $3; }
399;
400
401
402case_list:
403        /* empty */ { $$.op_type = IS_UNUSED; }
404    |   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; }
405    |   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; }
406;
407
408
409case_separator:
410        ':'
411    |   ';'
412;
413
414
415while_statement:
416        statement
417    |   ':' inner_statement_list T_ENDWHILE ';'
418;
419
420
421
422elseif_list:
423        /* empty */
424    |   elseif_list T_ELSEIF '(' expr ')' { zend_do_if_cond(&$4, &$5 TSRMLS_CC); } statement { zend_do_if_after_statement(&$5, 0 TSRMLS_CC); }
425;
426
427
428new_elseif_list:
429        /* empty */
430    |   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); }
431;
432
433
434else_single:
435        /* empty */
436    |   T_ELSE statement
437;
438
439
440new_else_single:
441        /* empty */
442    |   T_ELSE ':' inner_statement_list
443;
444
445
446parameter_list:
447        non_empty_parameter_list
448    |   /* empty */
449;
450
451
452non_empty_parameter_list:
453        optional_class_type T_VARIABLE              { znode tmp;  fetch_simple_variable(&tmp, &$2, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$1, &$2, 0 TSRMLS_CC); }
454    |   optional_class_type '&' T_VARIABLE          { znode tmp;  fetch_simple_variable(&tmp, &$3, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$1, &$3, 1 TSRMLS_CC); }
455    |   optional_class_type '&' T_VARIABLE '=' static_scalar            { znode tmp;  fetch_simple_variable(&tmp, &$3, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$5, &$1, &$3, 1 TSRMLS_CC); }
456    |   optional_class_type T_VARIABLE '=' static_scalar                { znode tmp;  fetch_simple_variable(&tmp, &$2, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$4, &$1, &$2, 0 TSRMLS_CC); }
457    |   non_empty_parameter_list ',' optional_class_type T_VARIABLE     { znode tmp;  fetch_simple_variable(&tmp, &$4, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$3, &$4, 0 TSRMLS_CC); }
458    |   non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE { znode tmp;  fetch_simple_variable(&tmp, &$5, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$3, &$5, 1 TSRMLS_CC); }
459    |   non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE  '=' static_scalar { znode tmp;  fetch_simple_variable(&tmp, &$5, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$7, &$3, &$5, 1 TSRMLS_CC); }
460    |   non_empty_parameter_list ',' optional_class_type T_VARIABLE '=' static_scalar   { znode tmp;  fetch_simple_variable(&tmp, &$4, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$6, &$3, &$4, 0 TSRMLS_CC); }
461;
462
463
464optional_class_type:
465        /* empty */                 { $$.op_type = IS_UNUSED; }
466    |   fully_qualified_class_name  { $$ = $1; }
467    |   T_ARRAY                     { $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_NULL;}
468;
469
470
471function_call_parameter_list:
472        non_empty_function_call_parameter_list  { $$ = $1; }
473    |   /* empty */             { Z_LVAL($$.u.constant) = 0; }
474;
475
476
477non_empty_function_call_parameter_list:
478        expr_without_variable   { Z_LVAL($$.u.constant) = 1;  zend_do_pass_param(&$1, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); }
479    |   variable                { Z_LVAL($$.u.constant) = 1;  zend_do_pass_param(&$1, ZEND_SEND_VAR, Z_LVAL($$.u.constant) TSRMLS_CC); }
480    |   '&' w_variable              { Z_LVAL($$.u.constant) = 1;  zend_do_pass_param(&$2, ZEND_SEND_REF, Z_LVAL($$.u.constant) TSRMLS_CC); }
481    |   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); }
482    |   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); }
483    |   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); }
484;
485
486global_var_list:
487        global_var_list ',' global_var  { zend_do_fetch_global_variable(&$3, NULL, ZEND_FETCH_GLOBAL_LOCK TSRMLS_CC); }
488    |   global_var                      { zend_do_fetch_global_variable(&$1, NULL, ZEND_FETCH_GLOBAL_LOCK TSRMLS_CC); }
489;
490
491
492global_var:
493        T_VARIABLE          { $$ = $1; }
494    |   '$' r_variable      { $$ = $2; }
495    |   '$' '{' expr '}'    { $$ = $3; }
496;
497
498
499static_var_list:
500        static_var_list ',' T_VARIABLE { zend_do_fetch_static_variable(&$3, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
501    |   static_var_list ',' T_VARIABLE '=' static_scalar { zend_do_fetch_static_variable(&$3, &$5, ZEND_FETCH_STATIC TSRMLS_CC); }
502    |   T_VARIABLE  { zend_do_fetch_static_variable(&$1, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
503    |   T_VARIABLE '=' static_scalar { zend_do_fetch_static_variable(&$1, &$3, ZEND_FETCH_STATIC TSRMLS_CC); }
504
505;
506
507
508class_statement_list:
509        class_statement_list class_statement
510    |   /* empty */
511;
512
513
514class_statement:
515        variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';'
516    |   class_constant_declaration ';'
517    |   method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); } '('
518            parameter_list ')' method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); }
519;
520
521
522method_body:
523        ';' /* abstract method */       { Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; }
524    |   '{' inner_statement_list '}'    { Z_LVAL($$.u.constant) = 0;    }
525;
526
527variable_modifiers:
528        non_empty_member_modifiers      { $$ = $1; }
529    |   T_VAR                           { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
530;
531
532method_modifiers:
533        /* empty */                         { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
534    |   non_empty_member_modifiers          { $$ = $1;  if (!(Z_LVAL($$.u.constant) & ZEND_ACC_PPP_MASK)) { Z_LVAL($$.u.constant) |= ZEND_ACC_PUBLIC; } }
535;
536
537non_empty_member_modifiers:
538        member_modifier                     { $$ = $1; }
539    |   non_empty_member_modifiers member_modifier  { Z_LVAL($$.u.constant) = zend_do_verify_access_types(&$1, &$2); }
540;
541
542member_modifier:
543        T_PUBLIC                { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
544    |   T_PROTECTED             { Z_LVAL($$.u.constant) = ZEND_ACC_PROTECTED; }
545    |   T_PRIVATE               { Z_LVAL($$.u.constant) = ZEND_ACC_PRIVATE; }
546    |   T_STATIC                { Z_LVAL($$.u.constant) = ZEND_ACC_STATIC; }
547    |   T_ABSTRACT              { Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; }
548    |   T_FINAL                 { Z_LVAL($$.u.constant) = ZEND_ACC_FINAL; }
549;
550
551class_variable_declaration:
552        class_variable_declaration ',' T_VARIABLE                   { zend_do_declare_property(&$3, NULL, CG(access_type) TSRMLS_CC); }
553    |   class_variable_declaration ',' T_VARIABLE '=' static_scalar { zend_do_declare_property(&$3, &$5, CG(access_type) TSRMLS_CC); }
554    |   T_VARIABLE                      { zend_do_declare_property(&$1, NULL, CG(access_type) TSRMLS_CC); }
555    |   T_VARIABLE '=' static_scalar    { zend_do_declare_property(&$1, &$3, CG(access_type) TSRMLS_CC); }
556;
557
558class_constant_declaration:
559        class_constant_declaration ',' T_STRING '=' static_scalar   { zend_do_declare_class_constant(&$3, &$5 TSRMLS_CC); }
560    |   T_CONST T_STRING '=' static_scalar  { zend_do_declare_class_constant(&$2, &$4 TSRMLS_CC); }
561;
562
563echo_expr_list:
564        echo_expr_list ',' expr { zend_do_echo(&$3 TSRMLS_CC); }
565    |   expr                    { zend_do_echo(&$1 TSRMLS_CC); }
566;
567
568
569for_expr:
570        /* empty */         { $$.op_type = IS_CONST;  Z_TYPE($$.u.constant) = IS_BOOL;  Z_LVAL($$.u.constant) = 1; }
571    |   non_empty_for_expr  { $$ = $1; }
572;
573
574non_empty_for_expr:
575        non_empty_for_expr ','  { zend_do_free(&$1 TSRMLS_CC); } expr { $$ = $4; }
576    |   expr                    { $$ = $1; }
577;
578
579expr_without_variable:
580        T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 TSRMLS_CC); }
581    |   variable '=' expr       { zend_check_writable_variable(&$1); zend_do_assign(&$$, &$1, &$3 TSRMLS_CC); }
582    |   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); }
583    |   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.u.EA.type = ZEND_PARSED_NEW; zend_do_assign_ref(&$$, &$1, &$3 TSRMLS_CC); }
584    |   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);}
585    |   T_CLONE expr { zend_do_clone(&$$, &$2 TSRMLS_CC); }
586    |   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); }
587    |   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); }
588    |   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); }
589    |   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); }
590    |   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); }
591    |   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); }
592    |   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); }
593    |   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); }
594    |   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); }
595    |   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); }
596    |   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); }
597    |   rw_variable T_INC { zend_do_post_incdec(&$$, &$1, ZEND_POST_INC TSRMLS_CC); }
598    |   T_INC rw_variable { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_INC TSRMLS_CC); }
599    |   rw_variable T_DEC { zend_do_post_incdec(&$$, &$1, ZEND_POST_DEC TSRMLS_CC); }
600    |   T_DEC rw_variable { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_DEC TSRMLS_CC); }
601    |   expr T_BOOLEAN_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
602    |   expr T_BOOLEAN_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
603    |   expr T_LOGICAL_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
604    |   expr T_LOGICAL_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
605    |   expr T_LOGICAL_XOR expr { zend_do_binary_op(ZEND_BOOL_XOR, &$$, &$1, &$3 TSRMLS_CC); }
606    |   expr '|' expr   { zend_do_binary_op(ZEND_BW_OR, &$$, &$1, &$3 TSRMLS_CC); }
607    |   expr '&' expr   { zend_do_binary_op(ZEND_BW_AND, &$$, &$1, &$3 TSRMLS_CC); }
608    |   expr '^' expr   { zend_do_binary_op(ZEND_BW_XOR, &$$, &$1, &$3 TSRMLS_CC); }
609    |   expr '.' expr   { zend_do_binary_op(ZEND_CONCAT, &$$, &$1, &$3 TSRMLS_CC); }
610    |   expr '+' expr   { zend_do_binary_op(ZEND_ADD, &$$, &$1, &$3 TSRMLS_CC); }
611    |   expr '-' expr   { zend_do_binary_op(ZEND_SUB, &$$, &$1, &$3 TSRMLS_CC); }
612    |   expr '*' expr   { zend_do_binary_op(ZEND_MUL, &$$, &$1, &$3 TSRMLS_CC); }
613    |   expr '/' expr   { zend_do_binary_op(ZEND_DIV, &$$, &$1, &$3 TSRMLS_CC); }
614    |   expr '%' expr   { zend_do_binary_op(ZEND_MOD, &$$, &$1, &$3 TSRMLS_CC); }
615    |   expr T_SL expr  { zend_do_binary_op(ZEND_SL, &$$, &$1, &$3 TSRMLS_CC); }
616    |   expr T_SR expr  { zend_do_binary_op(ZEND_SR, &$$, &$1, &$3 TSRMLS_CC); }
617    |   '+' 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); } }
618    |   '-' 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); } }
619    |   '!' expr { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$2 TSRMLS_CC); }
620    |   '~' expr { zend_do_unary_op(ZEND_BW_NOT, &$$, &$2 TSRMLS_CC); }
621    |   expr T_IS_IDENTICAL expr        { zend_do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
622    |   expr T_IS_NOT_IDENTICAL expr    { zend_do_binary_op(ZEND_IS_NOT_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
623    |   expr T_IS_EQUAL expr            { zend_do_binary_op(ZEND_IS_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
624    |   expr T_IS_NOT_EQUAL expr        { zend_do_binary_op(ZEND_IS_NOT_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
625    |   expr '<' expr                   { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$1, &$3 TSRMLS_CC); }
626    |   expr T_IS_SMALLER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
627    |   expr '>' expr                   { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 TSRMLS_CC); }
628    |   expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); }
629    |   expr T_INSTANCEOF class_name_reference { zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); }
630    |   '(' expr ')'    { $$ = $2; }
631    |   expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
632        expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
633        expr     { zend_do_qm_false(&$$, &$7, &$2, &$5 TSRMLS_CC); }
634    |   expr '?' ':' { zend_do_jmp_set(&$1, &$2, &$3 TSRMLS_CC); }
635        expr     { zend_do_jmp_set_else(&$$, &$5, &$2, &$3 TSRMLS_CC); }
636    |   internal_functions_in_yacc { $$ = $1; }
637    |   T_INT_CAST expr     { zend_do_cast(&$$, &$2, IS_LONG TSRMLS_CC); }
638    |   T_DOUBLE_CAST expr  { zend_do_cast(&$$, &$2, IS_DOUBLE TSRMLS_CC); }
639    |   T_STRING_CAST expr  { zend_do_cast(&$$, &$2, IS_STRING TSRMLS_CC); }
640    |   T_ARRAY_CAST expr   { zend_do_cast(&$$, &$2, IS_ARRAY TSRMLS_CC); }
641    |   T_OBJECT_CAST expr  { zend_do_cast(&$$, &$2, IS_OBJECT TSRMLS_CC); }
642    |   T_BOOL_CAST expr    { zend_do_cast(&$$, &$2, IS_BOOL TSRMLS_CC); }
643    |   T_UNSET_CAST expr   { zend_do_cast(&$$, &$2, IS_NULL TSRMLS_CC); }
644    |   T_EXIT exit_expr    { zend_do_exit(&$$, &$2 TSRMLS_CC); }
645    |   '@' { zend_do_begin_silence(&$1 TSRMLS_CC); } expr { zend_do_end_silence(&$1 TSRMLS_CC); $$ = $3; }
646    |   scalar              { $$ = $1; }
647    |   T_ARRAY '(' array_pair_list ')' { $$ = $3; }
648    |   '`' backticks_expr '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); }
649    |   T_PRINT expr  { zend_do_print(&$$, &$2 TSRMLS_CC); }
650    |   function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type TSRMLS_CC); }
651            parameter_list ')' lexical_vars '{' inner_statement_list '}' {  zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $4; }
652;
653
654function:
655    T_FUNCTION { $$.u.opline_num = CG(zend_lineno); }
656;
657
658lexical_vars:
659        /* empty */
660    |   T_USE '(' lexical_var_list ')'
661;
662
663lexical_var_list:
664        lexical_var_list ',' T_VARIABLE         { zend_do_fetch_lexical_variable(&$3, 0 TSRMLS_CC); }
665    |   lexical_var_list ',' '&' T_VARIABLE     { zend_do_fetch_lexical_variable(&$4, 1 TSRMLS_CC); }
666    |   T_VARIABLE                              { zend_do_fetch_lexical_variable(&$1, 0 TSRMLS_CC); }
667    |   '&' T_VARIABLE                          { zend_do_fetch_lexical_variable(&$2, 1 TSRMLS_CC); }
668;
669
670function_call:
671        namespace_name '(' { $2.u.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); }
672                function_call_parameter_list
673                ')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
674    |   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.opline_num = zend_do_begin_function_call(&$1, 0 TSRMLS_CC); }
675                function_call_parameter_list
676                ')' { zend_do_end_function_call(&$1, &$$, &$6, 0, $4.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
677    |   T_NS_SEPARATOR namespace_name '(' { $3.u.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
678                function_call_parameter_list
679                ')' { zend_do_end_function_call(&$2, &$$, &$5, 0, $3.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
680    |   class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { $4.u.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
681            function_call_parameter_list
682            ')' { zend_do_end_function_call($4.u.opline_num?NULL:&$3, &$$, &$6, $4.u.opline_num, $4.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
683    |   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); }
684            function_call_parameter_list
685            ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
686    |   variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
687            function_call_parameter_list
688            ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
689    |   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); }
690            function_call_parameter_list
691            ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
692    |   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); }
693            function_call_parameter_list ')'
694            { zend_do_end_function_call(&$1, &$$, &$4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
695;
696
697class_name:
698        T_STATIC { $$.op_type = IS_CONST; ZVAL_STRINGL(&$$.u.constant, "static", sizeof("static")-1, 1);}
699    |   namespace_name { $$ = $1; }
700    |   T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant);  zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); }
701    |   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; }
702;
703
704fully_qualified_class_name:
705        namespace_name { $$ = $1; }
706    |   T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant);  zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); }
707    |   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; }
708;
709
710
711
712class_name_reference:
713        class_name                      { zend_do_fetch_class(&$$, &$1 TSRMLS_CC); }
714    |   dynamic_class_name_reference    { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class(&$$, &$1 TSRMLS_CC); }
715;
716
717
718dynamic_class_name_reference:
719        base_variable T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
720            object_property { zend_do_push_object(&$4 TSRMLS_CC); zend_do_declare_implicit_property(TSRMLS_C); } dynamic_class_name_variable_properties
721            { zend_do_pop_object(&$$ TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_MEMBER; }
722    |   base_variable { $$ = $1; }
723;
724
725
726dynamic_class_name_variable_properties:
727        dynamic_class_name_variable_properties dynamic_class_name_variable_property
728    |   /* empty */
729;
730
731
732dynamic_class_name_variable_property:
733        T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); zend_do_declare_implicit_property(TSRMLS_C); }
734;
735
736exit_expr:
737        /* empty */ { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
738    |   '(' ')'     { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
739    |   '(' expr ')'    { $$ = $2; }
740;
741
742backticks_expr:
743        /* empty */ { ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; }
744    |   T_ENCAPSED_AND_WHITESPACE   { $$ = $1; }
745    |   encaps_list { $$ = $1; }
746;
747
748
749ctor_arguments:
750        /* empty */ { Z_LVAL($$.u.constant)=0; }
751    |   '(' function_call_parameter_list ')'    { $$ = $2; }
752;
753
754
755common_scalar:
756        T_LNUMBER                   { $$ = $1; }
757    |   T_DNUMBER                   { $$ = $1; }
758    |   T_CONSTANT_ENCAPSED_STRING  { $$ = $1; }
759    |   T_LINE                      { $$ = $1; }
760    |   T_FILE                      { $$ = $1; }
761    |   T_DIR                       { $$ = $1; }
762    |   T_CLASS_C                   { $$ = $1; }
763    |   T_METHOD_C                  { $$ = $1; }
764    |   T_FUNC_C                    { $$ = $1; }
765    |   T_NS_C                      { $$ = $1; }
766    |   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); }
767    |   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); }
768;
769
770
771static_scalar: /* compile-time evaluated scalars */
772        common_scalar       { $$ = $1; }
773    |   namespace_name      { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT, 1 TSRMLS_CC); }
774    |   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); }
775    |   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); }
776    |   '+' static_scalar { ZVAL_LONG(&$1.u.constant, 0); add_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
777    |   '-' static_scalar { ZVAL_LONG(&$1.u.constant, 0); sub_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
778    |   T_ARRAY '(' static_array_pair_list ')' { $$ = $3; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
779    |   static_class_constant { $$ = $1; }
780;
781
782static_class_constant:
783        class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_CT, 0 TSRMLS_CC); }
784;
785
786scalar:
787        T_STRING_VARNAME        { $$ = $1; }
788    |   class_constant      { $$ = $1; }
789    |   namespace_name  { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC); }
790    |   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); }
791    |   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); }
792    |   common_scalar           { $$ = $1; }
793    |   '"' encaps_list '"'     { $$ = $2; }
794    |   T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) = Z_STRLEN($1.u.constant); }
795;
796
797
798static_array_pair_list:
799        /* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); }
800    |   non_empty_static_array_pair_list possible_comma { $$ = $1; }
801;
802
803possible_comma:
804        /* empty */
805    |   ','
806;
807
808non_empty_static_array_pair_list:
809        non_empty_static_array_pair_list ',' static_scalar T_DOUBLE_ARROW static_scalar { zend_do_add_static_array_element(&$$, &$3, &$5); }
810    |   non_empty_static_array_pair_list ',' static_scalar { zend_do_add_static_array_element(&$$, NULL, &$3); }
811    |   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); }
812    |   static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, NULL, &$1); }
813;
814
815expr:
816        r_variable                  { $$ = $1; }
817    |   expr_without_variable       { $$ = $1; }
818;
819
820
821r_variable:
822    variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$ = $1; }
823;
824
825
826w_variable:
827    variable    { zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); $$ = $1;
828                  zend_check_writable_variable(&$1); }
829;
830
831rw_variable:
832    variable    { zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); $$ = $1;
833                  zend_check_writable_variable(&$1); }
834;
835
836variable:
837        base_variable_with_function_calls T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
838            object_property { zend_do_push_object(&$4 TSRMLS_CC); } method_or_not variable_properties
839            { zend_do_pop_object(&$$ TSRMLS_CC); $$.u.EA.type = $1.u.EA.type | ($7.u.EA.type ? $7.u.EA.type : $6.u.EA.type); }
840    |   base_variable_with_function_calls { $$ = $1; }
841;
842
843variable_properties:
844        variable_properties variable_property { $$.u.EA.type = $2.u.EA.type; }
845    |   /* empty */ { $$.u.EA.type = 0; }
846;
847
848
849variable_property:
850        T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); } method_or_not { $$.u.EA.type = $4.u.EA.type; }
851;
852
853method_or_not:
854        '(' { zend_do_pop_object(&$1 TSRMLS_CC); zend_do_begin_method_call(&$1 TSRMLS_CC); }
855                function_call_parameter_list ')'
856            { zend_do_end_function_call(&$1, &$$, &$3, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);
857              zend_do_push_object(&$$ TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_METHOD_CALL; }
858    |   /* empty */ { zend_do_declare_implicit_property(TSRMLS_C); $$.u.EA.type = ZEND_PARSED_MEMBER; }
859;
860
861variable_without_objects:
862        reference_variable { $$ = $1; }
863    |   simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); }
864;
865
866static_member:
867        class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
868    |   variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
869
870;
871
872variable_class_name:
873        reference_variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$=$1;; }
874;
875
876base_variable_with_function_calls:
877        base_variable       { $$ = $1; }
878    |   function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; $$.u.EA.type = ZEND_PARSED_FUNCTION_CALL; }
879;
880
881
882base_variable:
883        reference_variable { $$ = $1; $$.u.EA.type = ZEND_PARSED_VARIABLE; }
884    |   simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_VARIABLE; }
885    |   static_member { $$ = $1; $$.u.EA.type = ZEND_PARSED_STATIC_MEMBER; }
886;
887
888reference_variable:
889        reference_variable '[' dim_offset ']'   { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
890    |   reference_variable '{' expr '}'     { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
891    |   compound_variable           { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
892;
893
894
895compound_variable:
896        T_VARIABLE          { $$ = $1; }
897    |   '$' '{' expr '}'    { $$ = $3; }
898;
899
900dim_offset:
901        /* empty */     { $$.op_type = IS_UNUSED; }
902    |   expr            { $$ = $1; }
903;
904
905
906object_property:
907        object_dim_list { $$ = $1; }
908    |   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);}
909;
910
911object_dim_list:
912        object_dim_list '[' dim_offset ']'  { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
913    |   object_dim_list '{' expr '}'        { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
914    |   variable_name { znode tmp_znode;  zend_do_pop_object(&tmp_znode TSRMLS_CC);  zend_do_fetch_property(&$$, &tmp_znode, &$1 TSRMLS_CC);}
915;
916
917variable_name:
918        T_STRING        { $$ = $1; }
919    |   '{' expr '}'    { $$ = $2; }
920;
921
922simple_indirect_reference:
923        '$' { Z_LVAL($$.u.constant) = 1; }
924    |   simple_indirect_reference '$' { Z_LVAL($$.u.constant)++; }
925;
926
927assignment_list:
928        assignment_list ',' assignment_list_element
929    |   assignment_list_element
930;
931
932
933assignment_list_element:
934        variable                                { zend_do_add_list_element(&$1 TSRMLS_CC); }
935    |   T_LIST '(' { zend_do_new_list_begin(TSRMLS_C); } assignment_list ')'    { zend_do_new_list_end(TSRMLS_C); }
936    |   /* empty */                         { zend_do_add_list_element(NULL TSRMLS_CC); }
937;
938
939
940array_pair_list:
941        /* empty */ { zend_do_init_array(&$$, NULL, NULL, 0 TSRMLS_CC); }
942    |   non_empty_array_pair_list possible_comma    { $$ = $1; }
943;
944
945non_empty_array_pair_list:
946        non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr  { zend_do_add_array_element(&$$, &$5, &$3, 0 TSRMLS_CC); }
947    |   non_empty_array_pair_list ',' expr          { zend_do_add_array_element(&$$, &$3, NULL, 0 TSRMLS_CC); }
948    |   expr T_DOUBLE_ARROW expr    { zend_do_init_array(&$$, &$3, &$1, 0 TSRMLS_CC); }
949    |   expr                { zend_do_init_array(&$$, &$1, NULL, 0 TSRMLS_CC); }
950    |   non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_variable { zend_do_add_array_element(&$$, &$6, &$3, 1 TSRMLS_CC); }
951    |   non_empty_array_pair_list ',' '&' w_variable { zend_do_add_array_element(&$$, &$4, NULL, 1 TSRMLS_CC); }
952    |   expr T_DOUBLE_ARROW '&' w_variable  { zend_do_init_array(&$$, &$4, &$1, 1 TSRMLS_CC); }
953    |   '&' w_variable          { zend_do_init_array(&$$, &$2, NULL, 1 TSRMLS_CC); }
954;
955
956encaps_list:
957        encaps_list encaps_var { zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC);  zend_do_add_variable(&$$, &$1, &$2 TSRMLS_CC); }
958    |   encaps_list T_ENCAPSED_AND_WHITESPACE   { zend_do_add_string(&$$, &$1, &$2 TSRMLS_CC); }
959    |   encaps_var { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_add_variable(&$$, NULL, &$1 TSRMLS_CC); }
960    |   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); }
961;
962
963
964
965encaps_var:
966        T_VARIABLE { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
967    |   T_VARIABLE '[' { zend_do_begin_variable_parse(TSRMLS_C); } encaps_var_offset ']'    { fetch_array_begin(&$$, &$1, &$4 TSRMLS_CC); }
968    |   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); }
969    |   T_DOLLAR_OPEN_CURLY_BRACES expr '}' { zend_do_begin_variable_parse(TSRMLS_C);  fetch_simple_variable(&$$, &$2, 1 TSRMLS_CC); }
970    |   T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' { zend_do_begin_variable_parse(TSRMLS_C);  fetch_array_begin(&$$, &$2, &$4 TSRMLS_CC); }
971    |   T_CURLY_OPEN variable '}' { $$ = $2; }
972;
973
974
975encaps_var_offset:
976        T_STRING        { $$ = $1; }
977    |   T_NUM_STRING    { $$ = $1; }
978    |   T_VARIABLE      { fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
979;
980
981
982internal_functions_in_yacc:
983        T_ISSET '(' isset_variables ')' { $$ = $3; }
984    |   T_EMPTY '(' variable ')'    { zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 TSRMLS_CC); }
985    |   T_INCLUDE expr          { zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 TSRMLS_CC); }
986    |   T_INCLUDE_ONCE expr     { zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 TSRMLS_CC); }
987    |   T_EVAL '(' expr ')'     { zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 TSRMLS_CC); }
988    |   T_REQUIRE expr          { zend_do_include_or_eval(ZEND_REQUIRE, &$$, &$2 TSRMLS_CC); }
989    |   T_REQUIRE_ONCE expr     { zend_do_include_or_eval(ZEND_REQUIRE_ONCE, &$$, &$2 TSRMLS_CC); }
990;
991
992isset_variables:
993        variable                { zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$1 TSRMLS_CC); }
994    |   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); }
995;
996
997class_constant:
998        class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT, 0 TSRMLS_CC); }
999    |   variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT, 0 TSRMLS_CC); }
1000;
1001
1002%%
1003
1004/*
1005 * Local variables:
1006 * tab-width: 4
1007 * c-basic-offset: 4
1008 * indent-tabs-mode: t
1009 * End:
1010 */
1011