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