1999-04-08 02:10:10 +08:00
%{
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
2013-01-01 16:37:09 +08:00
| Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) |
1999-04-08 02:10:10 +08:00
+----------------------------------------------------------------------+
2001-12-11 23:16:21 +08:00
| This source file is subject to version 2.00 of the Zend license, |
2006-05-12 05:07:39 +08:00
| that is bundled with this package in the file LICENSE, and is |
2003-06-11 04:04:29 +08:00
| available through the world-wide-web at the following url: |
2001-12-11 23:16:21 +08:00
| http://www.zend.com/license/2_00.txt. |
1999-07-16 22:58:16 +08:00
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
1999-04-08 02:10:10 +08:00
+----------------------------------------------------------------------+
| Authors: Andi Gutmans <andi@zend.com> |
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
2003-02-01 09:49:15 +08:00
/* $Id$ */
2006-05-12 05:07:39 +08:00
/*
1999-04-08 02:10:10 +08:00
* LALR shift/reduce conflicts and how they are resolved:
*
2008-07-26 23:30:28 +08:00
* - 2 shift/reduce conflicts due to the dangling elseif/else ambiguity. Solved by shift.
2006-05-12 05:07:39 +08:00
*
1999-04-08 02:10:10 +08:00
*/
1999-12-06 23:31:06 +08:00
1999-04-08 02:10:10 +08:00
#include "zend_compile.h"
#include "zend.h"
#include "zend_list.h"
#include "zend_globals.h"
#include "zend_API.h"
2005-06-05 00:16:19 +08:00
#include "zend_constants.h"
2011-06-24 07:00:53 +08:00
#define YYSIZE_T size_t
#define yytnamerr zend_yytnamerr
static YYSIZE_T zend_yytnamerr(char*, const char*);
1999-04-08 02:10:10 +08:00
1999-12-07 14:19:42 +08:00
#define YYERROR_VERBOSE
#define YYSTYPE znode
1999-04-08 02:10:10 +08:00
%}
%pure_parser
2011-11-06 21:25:45 +08:00
%expect 3
1999-04-08 02:10:10 +08:00
2013-03-25 23:48:21 +08:00
%code requires {
#ifdef ZTS
# define YYPARSE_PARAM tsrm_ls
# define YYLEX_PARAM tsrm_ls
#endif
}
2011-06-24 07:00:53 +08:00
%token END 0 "end of file"
2000-08-10 03:22:35 +08:00
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
2011-06-24 07:00:53 +08:00
%token T_INCLUDE "include (T_INCLUDE)"
%token T_INCLUDE_ONCE "include_once (T_INCLUDE_ONCE)"
%token T_EVAL "eval (T_EVAL)"
%token T_REQUIRE "require (T_REQUIRE)"
%token T_REQUIRE_ONCE "require_once (T_REQUIRE_ONCE)"
1999-04-08 02:10:10 +08:00
%left ','
1999-04-23 07:08:42 +08:00
%left T_LOGICAL_OR
2011-06-24 07:00:53 +08:00
%token T_LOGICAL_OR "or (T_LOGICAL_OR)"
1999-04-23 07:08:42 +08:00
%left T_LOGICAL_XOR
2011-06-24 07:00:53 +08:00
%token T_LOGICAL_XOR "xor (T_LOGICAL_XOR)"
1999-04-23 07:08:42 +08:00
%left T_LOGICAL_AND
2011-06-24 07:00:53 +08:00
%token T_LOGICAL_AND "and (T_LOGICAL_AND)"
1999-04-23 07:08:42 +08:00
%right T_PRINT
2011-06-24 07:00:53 +08:00
%token T_PRINT "print (T_PRINT)"
2012-05-29 23:34:33 +08:00
%right T_YIELD
%token T_YIELD "yield (T_YIELD)"
2000-06-09 21:36:36 +08:00
%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
2011-06-24 07:00:53 +08:00
%token T_PLUS_EQUAL "+= (T_PLUS_EQUAL)"
%token T_MINUS_EQUAL "-= (T_MINUS_EQUAL)"
%token T_MUL_EQUAL "*= (T_MUL_EQUAL)"
%token T_DIV_EQUAL "/= (T_DIV_EQUAL)"
%token T_CONCAT_EQUAL ".= (T_CONCAT_EQUAL)"
%token T_MOD_EQUAL "%= (T_MOD_EQUAL)"
%token T_AND_EQUAL "&= (T_AND_EQUAL)"
%token T_OR_EQUAL "|= (T_OR_EQUAL)"
%token T_XOR_EQUAL "^= (T_XOR_EQUAL)"
%token T_SL_EQUAL "<<= (T_SL_EQUAL)"
%token T_SR_EQUAL ">>= (T_SR_EQUAL)"
1999-04-08 02:10:10 +08:00
%left '?' ':'
1999-04-23 07:08:42 +08:00
%left T_BOOLEAN_OR
2011-06-24 07:00:53 +08:00
%token T_BOOLEAN_OR "|| (T_BOOLEAN_OR)"
%left T_BOOLEAN_AND
%token T_BOOLEAN_AND "&& (T_BOOLEAN_AND)"
1999-04-08 02:10:10 +08:00
%left '|'
%left '^'
%left '&'
2000-03-30 06:05:19 +08:00
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
2011-06-24 07:00:53 +08:00
%token T_IS_EQUAL "== (T_IS_EQUAL)"
%token T_IS_NOT_EQUAL "!= (T_IS_NOT_EQUAL)"
%token T_IS_IDENTICAL "=== (T_IS_IDENTICAL)"
%token T_IS_NOT_IDENTICAL "!== (T_IS_NOT_IDENTICAL)"
1999-04-23 07:08:42 +08:00
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
2011-06-24 07:00:53 +08:00
%token T_IS_SMALLER_OR_EQUAL "<= (T_IS_SMALLER_OR_EQUAL)"
%token T_IS_GREATER_OR_EQUAL ">= (T_IS_GREATER_OR_EQUAL)"
1999-04-23 07:08:42 +08:00
%left T_SL T_SR
2011-06-24 07:00:53 +08:00
%token T_SL "<< (T_SL)"
%token T_SR ">> (T_SR)"
1999-04-08 02:10:10 +08:00
%left '+' '-' '.'
%left '*' '/' '%'
2004-02-24 02:17:16 +08:00
%right '!'
2004-02-23 16:40:39 +08:00
%nonassoc T_INSTANCEOF
2011-06-24 07:00:53 +08:00
%token T_INSTANCEOF "instanceof (T_INSTANCEOF)"
2011-06-03 09:09:32 +08:00
%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 '@'
2011-06-24 07:00:53 +08:00
%token T_INC "++ (T_INC)"
%token T_DEC "-- (T_DEC)"
%token T_INT_CAST "(int) (T_INT_CAST)"
%token T_DOUBLE_CAST "(double) (T_DOUBLE_CAST)"
%token T_STRING_CAST "(string) (T_STRING_CAST)"
%token T_ARRAY_CAST "(array) (T_ARRAY_CAST)"
%token T_OBJECT_CAST "(object) (T_OBJECT_CAST)"
%token T_BOOL_CAST "(bool) (T_BOOL_CAST)"
%token T_UNSET_CAST "(unset) (T_UNSET_CAST)"
1999-04-08 02:10:10 +08:00
%right '['
2004-02-23 16:40:39 +08:00
%nonassoc T_NEW T_CLONE
2011-06-24 07:00:53 +08:00
%token T_NEW "new (T_NEW)"
%token T_CLONE "clone (T_CLONE)"
%token T_EXIT "exit (T_EXIT)"
%token T_IF "if (T_IF)"
1999-04-23 07:08:42 +08:00
%left T_ELSEIF
2011-06-24 07:00:53 +08:00
%token T_ELSEIF "elseif (T_ELSEIF)"
%left T_ELSE
%token T_ELSE "else (T_ELSE)"
%left T_ENDIF
%token T_ENDIF "endif (T_ENDIF)"
%token T_LNUMBER "integer number (T_LNUMBER)"
%token T_DNUMBER "floating-point number (T_DNUMBER)"
%token T_STRING "identifier (T_STRING)"
%token T_STRING_VARNAME "variable name (T_STRING_VARNAME)"
%token T_VARIABLE "variable (T_VARIABLE)"
%token T_NUM_STRING "number (T_NUM_STRING)"
1999-04-23 07:08:42 +08:00
%token T_INLINE_HTML
%token T_CHARACTER
%token T_BAD_CHARACTER
2011-06-24 07:00:53 +08:00
%token T_ENCAPSED_AND_WHITESPACE "quoted-string and whitespace (T_ENCAPSED_AND_WHITESPACE)"
%token T_CONSTANT_ENCAPSED_STRING "quoted-string (T_CONSTANT_ENCAPSED_STRING)"
%token T_ECHO "echo (T_ECHO)"
%token T_DO "do (T_DO)"
%token T_WHILE "while (T_WHILE)"
%token T_ENDWHILE "endwhile (T_ENDWHILE)"
%token T_FOR "for (T_FOR)"
%token T_ENDFOR "endfor (T_ENDFOR)"
%token T_FOREACH "foreach (T_FOREACH)"
%token T_ENDFOREACH "endforeach (T_ENDFOREACH)"
%token T_DECLARE "declare (T_DECLARE)"
%token T_ENDDECLARE "enddeclare (T_ENDDECLARE)"
%token T_AS "as (T_AS)"
%token T_SWITCH "switch (T_SWITCH)"
%token T_ENDSWITCH "endswitch (T_ENDSWITCH)"
%token T_CASE "case (T_CASE)"
%token T_DEFAULT "default (T_DEFAULT)"
%token T_BREAK "break (T_BREAK)"
%token T_CONTINUE "continue (T_CONTINUE)"
%token T_GOTO "goto (T_GOTO)"
%token T_FUNCTION "function (T_FUNCTION)"
%token T_CONST "const (T_CONST)"
%token T_RETURN "return (T_RETURN)"
%token T_TRY "try (T_TRY)"
%token T_CATCH "catch (T_CATCH)"
2012-08-13 21:48:39 +08:00
%token T_FINALLY "finally (T_FINALLY)"
2011-06-24 07:00:53 +08:00
%token T_THROW "throw (T_THROW)"
%token T_USE "use (T_USE)"
%token T_INSTEADOF "insteadof (T_INSTEADOF)"
%token T_GLOBAL "global (T_GLOBAL)"
2003-02-24 20:05:58 +08:00
%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
2011-06-24 07:00:53 +08:00
%token T_STATIC "static (T_STATIC)"
%token T_ABSTRACT "abstract (T_ABSTRACT)"
%token T_FINAL "final (T_FINAL)"
%token T_PRIVATE "private (T_PRIVATE)"
%token T_PROTECTED "protected (T_PROTECTED)"
%token T_PUBLIC "public (T_PUBLIC)"
%token T_VAR "var (T_VAR)"
%token T_UNSET "unset (T_UNSET)"
%token T_ISSET "isset (T_ISSET)"
%token T_EMPTY "empty (T_EMPTY)"
%token T_HALT_COMPILER "__halt_compiler (T_HALT_COMPILER)"
%token T_CLASS "class (T_CLASS)"
%token T_TRAIT "trait (T_TRAIT)"
%token T_INTERFACE "interface (T_INTERFACE)"
%token T_EXTENDS "extends (T_EXTENDS)"
%token T_IMPLEMENTS "implements (T_IMPLEMENTS)"
%token T_OBJECT_OPERATOR "-> (T_OBJECT_OPERATOR)"
%token T_DOUBLE_ARROW "=> (T_DOUBLE_ARROW)"
%token T_LIST "list (T_LIST)"
%token T_ARRAY "array (T_ARRAY)"
2011-08-16 18:44:47 +08:00
%token T_CALLABLE "callable (T_CALLABLE)"
2011-06-24 07:00:53 +08:00
%token T_CLASS_C "__CLASS__ (T_CLASS_C)"
2011-08-01 01:39:30 +08:00
%token T_TRAIT_C "__TRAIT__ (T_TRAIT_C)"
2011-06-24 07:00:53 +08:00
%token T_METHOD_C "__METHOD__ (T_METHOD_C)"
%token T_FUNC_C "__FUNCTION__ (T_FUNC_C)"
%token T_LINE "__LINE__ (T_LINE)"
%token T_FILE "__FILE__ (T_FILE)"
%token T_COMMENT "comment (T_COMMENT)"
%token T_DOC_COMMENT "doc comment (T_DOC_COMMENT)"
%token T_OPEN_TAG "open tag (T_OPEN_TAG)"
%token T_OPEN_TAG_WITH_ECHO "open tag with echo (T_OPEN_TAG_WITH_ECHO)"
%token T_CLOSE_TAG "close tag (T_CLOSE_TAG)"
%token T_WHITESPACE "whitespace (T_WHITESPACE)"
%token T_START_HEREDOC "heredoc start (T_START_HEREDOC)"
%token T_END_HEREDOC "heredoc end (T_END_HEREDOC)"
%token T_DOLLAR_OPEN_CURLY_BRACES "${ (T_DOLLAR_OPEN_CURLY_BRACES)"
%token T_CURLY_OPEN "{$ (T_CURLY_OPEN)"
%token T_PAAMAYIM_NEKUDOTAYIM ":: (T_PAAMAYIM_NEKUDOTAYIM)"
%token T_NAMESPACE "namespace (T_NAMESPACE)"
%token T_NS_C "__NAMESPACE__ (T_NS_C)"
%token T_DIR "__DIR__ (T_DIR)"
%token T_NS_SEPARATOR "\\ (T_NS_SEPARATOR)"
1999-04-08 02:10:10 +08:00
%% /* Rules */
2000-01-29 06:23:28 +08:00
start:
2007-09-29 03:52:53 +08:00
top_statement_list { zend_do_end_compilation(TSRMLS_C); }
2000-01-29 06:23:28 +08:00
;
2001-07-28 18:51:54 +08:00
top_statement_list:
2001-07-30 12:54:16 +08:00
top_statement_list { zend_do_extended_info(TSRMLS_C); } top_statement { HANDLE_INTERACTIVE(); }
1999-04-08 02:10:10 +08:00
| /* empty */
;
2007-09-29 03:52:53 +08:00
namespace_name:
T_STRING { $$ = $1; }
2008-11-04 23:58:55 +08:00
| namespace_name T_NS_SEPARATOR T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
2007-09-29 03:52:53 +08:00
;
1999-04-08 02:10:10 +08:00
1999-05-15 23:47:24 +08:00
top_statement:
2008-11-25 17:56:32 +08:00
statement { zend_verify_namespace(TSRMLS_C); }
| function_declaration_statement { zend_verify_namespace(TSRMLS_C); zend_do_early_binding(TSRMLS_C); }
| class_declaration_statement { zend_verify_namespace(TSRMLS_C); zend_do_early_binding(TSRMLS_C); }
2007-09-29 03:52:53 +08:00
| T_HALT_COMPILER '(' ')' ';' { zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; }
2008-11-25 17:56:32 +08:00
| T_NAMESPACE namespace_name ';' { zend_do_begin_namespace(&$2, 0 TSRMLS_CC); }
| T_NAMESPACE namespace_name '{' { zend_do_begin_namespace(&$2, 1 TSRMLS_CC); }
top_statement_list '}' { zend_do_end_namespace(TSRMLS_C); }
| T_NAMESPACE '{' { zend_do_begin_namespace(NULL, 1 TSRMLS_CC); }
top_statement_list '}' { zend_do_end_namespace(TSRMLS_C); }
| T_USE use_declarations ';' { zend_verify_namespace(TSRMLS_C); }
| constant_declaration ';' { zend_verify_namespace(TSRMLS_C); }
1999-05-15 23:47:24 +08:00
;
2008-06-08 17:38:47 +08:00
use_declarations:
use_declarations ',' use_declaration
| use_declaration
2008-08-12 18:23:02 +08:00
;
2008-06-08 17:38:47 +08:00
use_declaration:
namespace_name { zend_do_use(&$1, NULL, 0 TSRMLS_CC); }
| namespace_name T_AS T_STRING { zend_do_use(&$1, &$3, 0 TSRMLS_CC); }
2008-11-18 02:00:44 +08:00
| T_NS_SEPARATOR namespace_name { zend_do_use(&$2, NULL, 1 TSRMLS_CC); }
| T_NS_SEPARATOR namespace_name T_AS T_STRING { zend_do_use(&$2, &$4, 1 TSRMLS_CC); }
2008-08-12 18:23:02 +08:00
;
2008-06-08 17:38:47 +08:00
2007-09-29 03:52:53 +08:00
constant_declaration:
constant_declaration ',' T_STRING '=' static_scalar { zend_do_declare_constant(&$3, &$5 TSRMLS_CC); }
| T_CONST T_STRING '=' static_scalar { zend_do_declare_constant(&$2, &$4 TSRMLS_CC); }
;
1999-05-15 23:47:24 +08:00
inner_statement_list:
2001-07-30 12:54:16 +08:00
inner_statement_list { zend_do_extended_info(TSRMLS_C); } inner_statement { HANDLE_INTERACTIVE(); }
1999-05-15 23:47:24 +08:00
| /* empty */
;
inner_statement:
statement
2002-09-24 01:20:59 +08:00
| function_declaration_statement
2004-01-12 03:37:15 +08:00
| class_declaration_statement
2005-06-05 00:16:19 +08:00
| T_HALT_COMPILER '(' ')' ';' { zend_error(E_COMPILE_ERROR, "__HALT_COMPILER() can only be used from the outermost scope"); }
1999-05-15 23:47:24 +08:00
;
1999-04-08 02:10:10 +08:00
statement:
2011-06-12 09:43:10 +08:00
unticked_statement { DO_TICKS(); }
2008-03-28 22:35:01 +08:00
| T_STRING ':' { zend_do_label(&$1 TSRMLS_CC); }
2000-01-25 03:00:30 +08:00
;
unticked_statement:
1999-05-15 23:47:24 +08:00
'{' inner_statement_list '}'
2012-07-22 03:05:46 +08:00
| T_IF parenthesis_expr { zend_do_if_cond(&$2, &$1 TSRMLS_CC); } statement { zend_do_if_after_statement(&$1, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); }
| T_IF parenthesis_expr ':' { zend_do_if_cond(&$2, &$1 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$1, 1 TSRMLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(TSRMLS_C); }
| T_WHILE { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); } parenthesis_expr { zend_do_while_cond(&$3, &$$ TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$4 TSRMLS_CC); }
| T_DO { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE { $4.u.op.opline_num = get_next_op_number(CG(active_op_array)); } parenthesis_expr ';' { zend_do_do_while_end(&$1, &$4, &$6 TSRMLS_CC); }
2006-05-12 05:07:39 +08:00
| T_FOR
1999-04-08 02:10:10 +08:00
'('
for_expr
2010-04-20 18:57:45 +08:00
';' { zend_do_free(&$3 TSRMLS_CC); $4.u.op.opline_num = get_next_op_number(CG(active_op_array)); }
1999-04-08 02:10:10 +08:00
for_expr
2001-07-28 18:51:54 +08:00
';' { zend_do_extended_info(TSRMLS_C); zend_do_for_cond(&$6, &$7 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
for_expr
2001-07-28 18:51:54 +08:00
')' { zend_do_free(&$9 TSRMLS_CC); zend_do_for_before_statement(&$4, &$7 TSRMLS_CC); }
for_statement { zend_do_for_end(&$7 TSRMLS_CC); }
2012-07-22 03:05:46 +08:00
| T_SWITCH parenthesis_expr { zend_do_switch_cond(&$2 TSRMLS_CC); } switch_case_list { zend_do_switch_end(&$4 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| T_BREAK ';' { zend_do_brk_cont(ZEND_BRK, NULL TSRMLS_CC); }
| T_BREAK expr ';' { zend_do_brk_cont(ZEND_BRK, &$2 TSRMLS_CC); }
| T_CONTINUE ';' { zend_do_brk_cont(ZEND_CONT, NULL TSRMLS_CC); }
| T_CONTINUE expr ';' { zend_do_brk_cont(ZEND_CONT, &$2 TSRMLS_CC); }
| T_RETURN ';' { zend_do_return(NULL, 0 TSRMLS_CC); }
| T_RETURN expr_without_variable ';' { zend_do_return(&$2, 0 TSRMLS_CC); }
2002-03-19 04:27:03 +08:00
| T_RETURN variable ';' { zend_do_return(&$2, 1 TSRMLS_CC); }
2012-12-19 22:21:34 +08:00
| yield_expr ';' { zend_do_free(&$1 TSRMLS_CC); }
2000-06-03 00:50:19 +08:00
| T_GLOBAL global_var_list ';'
| T_STATIC static_var_list ';'
1999-04-23 07:08:42 +08:00
| T_ECHO echo_expr_list ';'
2001-07-28 18:51:54 +08:00
| T_INLINE_HTML { zend_do_echo(&$1 TSRMLS_CC); }
| expr ';' { zend_do_free(&$1 TSRMLS_CC); }
2000-06-16 02:48:33 +08:00
| T_UNSET '(' unset_variables ')' ';'
2007-01-10 23:58:08 +08:00
| T_FOREACH '(' variable T_AS
{ zend_do_foreach_begin(&$1, &$2, &$3, &$4, 1 TSRMLS_CC); }
foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); }
| T_FOREACH '(' expr_without_variable T_AS
{ zend_do_foreach_begin(&$1, &$2, &$3, &$4, 0 TSRMLS_CC); }
2012-07-22 20:33:25 +08:00
foreach_variable foreach_optional_arg ')' { zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
2007-01-10 23:58:08 +08:00
foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); }
2010-04-20 18:57:45 +08:00
| 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); }
1999-04-08 02:10:10 +08:00
| ';' /* empty statement */
2001-09-04 00:57:49 +08:00
| T_TRY { zend_do_try(&$1 TSRMLS_CC); } '{' inner_statement_list '}'
2012-08-14 08:59:40 +08:00
catch_statement { zend_do_bind_catch(&$1, &$6 TSRMLS_CC); }
finally_statement { zend_do_end_finally(&$1, &$6, &$8 TSRMLS_CC); }
2001-09-04 00:57:49 +08:00
| T_THROW expr ';' { zend_do_throw(&$2 TSRMLS_CC); }
2008-03-28 22:35:01 +08:00
| T_GOTO T_STRING ';' { zend_do_goto(&$2 TSRMLS_CC); }
2002-03-03 04:38:52 +08:00
;
2012-08-13 21:48:39 +08:00
catch_statement:
2012-08-14 08:59:40 +08:00
/* empty */ { $$.op_type = IS_UNUSED; }
| T_CATCH '(' { zend_initialize_try_catch_element(&$1 TSRMLS_CC); }
fully_qualified_class_name { zend_do_first_catch(&$2 TSRMLS_CC); }
T_VARIABLE ')' { zend_do_begin_catch(&$1, &$4, &$6, &$2 TSRMLS_CC); }
2012-08-13 21:48:39 +08:00
'{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
additional_catches { zend_do_mark_last_catch(&$2, &$13 TSRMLS_CC); $$ = $1;}
finally_statement:
2012-08-14 08:59:40 +08:00
/* empty */ { $$.op_type = IS_UNUSED; }
| T_FINALLY { zend_do_finally(&$1 TSRMLS_CC); } '{' inner_statement_list '}' { $$ = $1; }
2012-08-13 21:48:39 +08:00
;
2002-03-03 04:38:52 +08:00
2002-03-01 22:04:51 +08:00
additional_catches:
2004-02-03 20:17:09 +08:00
non_empty_additional_catches { $$ = $1; }
2010-04-20 18:57:45 +08:00
| /* empty */ { $$.u.op.opline_num = -1; }
2002-03-01 22:04:51 +08:00
;
non_empty_additional_catches:
2004-04-20 22:14:55 +08:00
additional_catch { $$ = $1; }
| non_empty_additional_catches additional_catch { $$ = $2; }
;
2006-05-12 05:07:39 +08:00
2004-04-20 22:14:55 +08:00
additional_catch:
2010-04-20 18:57:45 +08:00
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); }
2002-02-14 03:26:07 +08:00
;
2000-06-16 02:48:33 +08:00
unset_variables:
unset_variable
| unset_variables ',' unset_variable
;
unset_variable:
2008-05-07 20:04:39 +08:00
variable { zend_do_end_variable_parse(&$1, BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1 TSRMLS_CC); }
2000-06-16 02:48:33 +08:00
;
1999-04-08 02:10:10 +08:00
2002-09-24 01:20:59 +08:00
function_declaration_statement:
2011-06-12 09:43:10 +08:00
unticked_function_declaration_statement { DO_TICKS(); }
2002-09-24 01:20:59 +08:00
;
class_declaration_statement:
2011-06-12 09:43:10 +08:00
unticked_class_declaration_statement { DO_TICKS(); }
2000-01-25 03:00:30 +08:00
;
2002-12-07 01:09:44 +08:00
is_reference:
/* empty */ { $$.op_type = ZEND_RETURN_VAL; }
| '&' { $$.op_type = ZEND_RETURN_REF; }
;
2002-09-24 01:20:59 +08:00
unticked_function_declaration_statement:
2012-07-20 06:49:50 +08:00
function is_reference T_STRING { zend_do_begin_function_declaration(&$1, &$3, 0, $2.op_type, NULL TSRMLS_CC); }
'(' parameter_list ')'
2012-05-20 02:19:45 +08:00
'{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); }
2002-09-24 01:20:59 +08:00
;
unticked_class_declaration_statement:
2003-04-03 00:13:12 +08:00
class_entry_type T_STRING extends_from
2006-05-12 05:07:39 +08:00
{ zend_do_begin_class_declaration(&$1, &$2, &$3 TSRMLS_CC); }
2003-03-05 19:14:44 +08:00
implements_list
'{'
class_statement_list
2013-01-09 21:16:47 +08:00
'}' { zend_do_end_class_declaration(&$1, &$3 TSRMLS_CC); }
2004-02-12 06:13:39 +08:00
| interface_entry T_STRING
2006-05-12 05:07:39 +08:00
{ zend_do_begin_class_declaration(&$1, &$2, NULL TSRMLS_CC); }
2004-02-12 06:13:39 +08:00
interface_extends_list
'{'
class_statement_list
2013-01-09 21:16:47 +08:00
'}' { zend_do_end_class_declaration(&$1, NULL TSRMLS_CC); }
2003-03-05 19:14:44 +08:00
;
class_entry_type:
2010-04-20 18:57:45 +08:00
T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = 0; }
| T_ABSTRACT T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; }
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
| T_TRAIT { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_TRAIT; }
2010-04-20 18:57:45 +08:00
| T_FINAL T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_FINAL_CLASS; }
2002-07-18 02:36:29 +08:00
;
extends_from:
2003-02-16 19:12:43 +08:00
/* empty */ { $$.op_type = IS_UNUSED; }
2007-09-29 03:52:53 +08:00
| T_EXTENDS fully_qualified_class_name { zend_do_fetch_class(&$$, &$2 TSRMLS_CC); }
2003-03-05 19:14:44 +08:00
;
2004-02-12 06:13:39 +08:00
interface_entry:
2010-04-20 18:57:45 +08:00
T_INTERFACE { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_INTERFACE; }
2004-02-12 06:13:39 +08:00
;
interface_extends_list:
/* empty */
| T_EXTENDS interface_list
;
2003-03-05 19:14:44 +08:00
implements_list:
/* empty */
| T_IMPLEMENTS interface_list
1999-05-15 23:47:24 +08:00
;
2003-03-05 19:14:44 +08:00
interface_list:
fully_qualified_class_name { zend_do_implements_interface(&$1 TSRMLS_CC); }
| interface_list ',' fully_qualified_class_name { zend_do_implements_interface(&$3 TSRMLS_CC); }
2001-12-22 23:31:44 +08:00
;
1999-05-15 23:47:24 +08:00
1999-04-08 02:10:10 +08:00
foreach_optional_arg:
2003-07-24 20:38:33 +08:00
/* empty */ { $$.op_type = IS_UNUSED; }
| T_DOUBLE_ARROW foreach_variable { $$ = $2; }
;
foreach_variable:
2005-10-17 15:57:00 +08:00
variable { zend_check_writable_variable(&$1); $$ = $1; }
2010-04-20 18:57:45 +08:00
| '&' variable { zend_check_writable_variable(&$2); $$ = $2; $$.EA |= ZEND_PARSED_REFERENCE_VARIABLE; }
2012-08-25 22:23:14 +08:00
| T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' { $$ = $1; $$.EA = ZEND_PARSED_LIST_EXPR; }
1999-04-08 02:10:10 +08:00
;
for_statement:
statement
1999-05-15 23:47:24 +08:00
| ':' inner_statement_list T_ENDFOR ';'
1999-04-08 02:10:10 +08:00
;
foreach_statement:
statement
1999-05-15 23:47:24 +08:00
| ':' inner_statement_list T_ENDFOREACH ';'
1999-04-08 02:10:10 +08:00
;
2000-01-25 03:00:30 +08:00
declare_statement:
statement
| ':' inner_statement_list T_ENDDECLARE ';'
;
declare_list:
2001-07-28 18:51:54 +08:00
T_STRING '=' static_scalar { zend_do_declare_stmt(&$1, &$3 TSRMLS_CC); }
| declare_list ',' T_STRING '=' static_scalar { zend_do_declare_stmt(&$3, &$5 TSRMLS_CC); }
2000-01-25 03:00:30 +08:00
;
1999-04-08 02:10:10 +08:00
switch_case_list:
2000-07-03 00:06:45 +08:00
'{' case_list '}' { $$ = $2; }
| '{' ';' case_list '}' { $$ = $3; }
2000-07-03 00:00:00 +08:00
| ':' case_list T_ENDSWITCH ';' { $$ = $2; }
| ':' ';' case_list T_ENDSWITCH ';' { $$ = $3; }
1999-04-08 02:10:10 +08:00
;
case_list:
2000-04-11 02:02:40 +08:00
/* empty */ { $$.op_type = IS_UNUSED; }
2002-01-19 18:35:51 +08:00
| 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; }
2001-07-28 18:51:54 +08:00
| 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; }
1999-04-08 02:10:10 +08:00
;
case_separator:
':'
| ';'
;
while_statement:
statement
1999-05-15 23:47:24 +08:00
| ':' inner_statement_list T_ENDWHILE ';'
1999-04-08 02:10:10 +08:00
;
elseif_list:
/* empty */
2012-07-22 03:05:46 +08:00
| elseif_list T_ELSEIF parenthesis_expr { zend_do_if_cond(&$3, &$2 TSRMLS_CC); } statement { zend_do_if_after_statement(&$2, 0 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
new_elseif_list:
/* empty */
2012-07-22 03:05:46 +08:00
| new_elseif_list T_ELSEIF parenthesis_expr ':' { zend_do_if_cond(&$3, &$2 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$2, 0 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
else_single:
/* empty */
1999-04-23 07:08:42 +08:00
| T_ELSE statement
1999-04-08 02:10:10 +08:00
;
new_else_single:
/* empty */
1999-05-15 23:47:24 +08:00
| T_ELSE ':' inner_statement_list
1999-04-08 02:10:10 +08:00
;
2006-05-12 05:07:39 +08:00
parameter_list:
1999-04-08 02:10:10 +08:00
non_empty_parameter_list
| /* empty */
;
non_empty_parameter_list:
2010-04-20 19:16:39 +08:00
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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
1999-04-08 02:10:10 +08:00
;
2003-03-06 22:31:17 +08:00
optional_class_type:
2007-10-01 18:37:14 +08:00
/* empty */ { $$.op_type = IS_UNUSED; }
2011-08-16 18:44:47 +08:00
| T_ARRAY { $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_ARRAY; }
| T_CALLABLE { $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_CALLABLE; }
2011-06-03 09:09:32 +08:00
| fully_qualified_class_name { $$ = $1; }
2003-03-06 22:31:17 +08:00
;
2003-05-30 03:27:11 +08:00
1999-04-08 02:10:10 +08:00
function_call_parameter_list:
2012-07-22 03:05:46 +08:00
'(' ')' { Z_LVAL($$.u.constant) = 0; }
| '(' non_empty_function_call_parameter_list ')' { $$ = $2; }
| '(' yield_expr ')' { Z_LVAL($$.u.constant) = 1; zend_do_pass_param(&$2, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
non_empty_function_call_parameter_list:
2006-05-12 05:07:39 +08:00
expr_without_variable { Z_LVAL($$.u.constant) = 1; zend_do_pass_param(&$1, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); }
| variable { Z_LVAL($$.u.constant) = 1; zend_do_pass_param(&$1, ZEND_SEND_VAR, Z_LVAL($$.u.constant) TSRMLS_CC); }
| '&' w_variable { Z_LVAL($$.u.constant) = 1; zend_do_pass_param(&$2, ZEND_SEND_REF, Z_LVAL($$.u.constant) TSRMLS_CC); }
| 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); }
| 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); }
| 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); }
1999-04-08 02:10:10 +08:00
;
global_var_list:
2005-07-04 21:24:46 +08:00
global_var_list ',' global_var { zend_do_fetch_global_variable(&$3, NULL, ZEND_FETCH_GLOBAL_LOCK TSRMLS_CC); }
| global_var { zend_do_fetch_global_variable(&$1, NULL, ZEND_FETCH_GLOBAL_LOCK TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
global_var:
2000-07-03 00:06:45 +08:00
T_VARIABLE { $$ = $1; }
2003-02-16 19:12:43 +08:00
| '$' r_variable { $$ = $2; }
1999-04-08 02:10:10 +08:00
| '$' '{' expr '}' { $$ = $3; }
;
static_var_list:
2002-11-11 01:50:27 +08:00
static_var_list ',' T_VARIABLE { zend_do_fetch_static_variable(&$3, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
| static_var_list ',' T_VARIABLE '=' static_scalar { zend_do_fetch_static_variable(&$3, &$5, ZEND_FETCH_STATIC TSRMLS_CC); }
| T_VARIABLE { zend_do_fetch_static_variable(&$1, NULL, ZEND_FETCH_STATIC TSRMLS_CC); }
| T_VARIABLE '=' static_scalar { zend_do_fetch_static_variable(&$1, &$3, ZEND_FETCH_STATIC TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
class_statement_list:
class_statement_list class_statement
| /* empty */
;
class_statement:
2006-05-12 05:07:39 +08:00
variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';'
2002-07-07 00:48:13 +08:00
| class_constant_declaration ';'
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
| trait_use_statement
2012-07-20 06:49:50 +08:00
| method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); }
'(' parameter_list ')'
method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
trait_use_statement:
T_USE trait_list trait_adaptations
;
trait_list:
2012-12-25 14:23:08 +08:00
fully_qualified_class_name { zend_do_use_trait(&$1 TSRMLS_CC); }
| trait_list ',' fully_qualified_class_name { zend_do_use_trait(&$3 TSRMLS_CC); }
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
;
trait_adaptations:
';'
| '{' trait_adaptation_list '}'
;
trait_adaptation_list:
/* empty */
| non_empty_trait_adaptation_list
;
non_empty_trait_adaptation_list:
trait_adaptation_statement
| non_empty_trait_adaptation_list trait_adaptation_statement
;
trait_adaptation_statement:
2012-12-25 14:23:08 +08:00
trait_precedence ';'
| trait_alias ';'
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
;
trait_precedence:
2012-12-25 14:23:08 +08:00
trait_method_reference_fully_qualified T_INSTEADOF trait_reference_list { zend_add_trait_precedence(&$1, &$3 TSRMLS_CC); }
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
;
trait_reference_list:
2011-07-10 01:27:59 +08:00
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); }
| 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; }
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
;
trait_method_reference:
T_STRING { zend_prepare_reference(&$$, NULL, &$1 TSRMLS_CC); }
| trait_method_reference_fully_qualified { $$ = $1; }
;
trait_method_reference_fully_qualified:
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_prepare_reference(&$$, &$1, &$3 TSRMLS_CC); }
;
trait_alias:
2012-12-25 14:23:08 +08:00
trait_method_reference T_AS trait_modifiers T_STRING { zend_add_trait_alias(&$1, &$3, &$4 TSRMLS_CC); }
| trait_method_reference T_AS member_modifier { zend_add_trait_alias(&$1, &$3, NULL TSRMLS_CC); }
Implemented Traits for PHP as proposed in the RFC [TRAITS]
# RFC http://wiki.php.net/rfc/horizontalreuse#traits_-_reuse_of_behavior
# Ok, here we go, I guess that will result in more discussion, which is fine
# by me. But now, the patch is here, and properly archived.
#
# See below a list of notes to the patch, it also includes a list of
# points which should be fixed
#
# Internals of the Traits Patch
# -----------------------------
#
# Open TODOs
# """"""""""
#
# - Reflection API
# - support for traits for internal classes
# - currently destroy_zend_class does not handle that case
#
# Introduced Structures
# """""""""""""""""""""
#
# Data structures to encode the composition information specified in the
# source:
# - zend_trait_method_reference
# - zend_trait_precedence
# - zend_trait_alias
#
# Changes
# """""""
#
# zend_class_entry
# - uses NULL terminated lists of pointers for
# - trait_aliases
# - trait_precedences
# - do you prefer an explicit counter?
# - the information is only necessary during class composition
# but might be interesting for reflection
# - did not want to blow up class further with not really necessary length counters
#
# added keywords
# - trait
# - insteadof
#
# Added opcodes
# ZEND_ADD_TRAIT
# - similar to ZEND_ADD_INTERFACE
# - adds the trait to the list of traits of a class, no actual composition done
# ZEND_BIND_TRAITS
# - emitted in zend_do_end_class_declaration
# - concludes the class definition and will initiate the trait composition
# when the class definition is encountered during runtime
#
# Added Flags
# ZEND_ACC_TRAIT = 0x120
# ZEND_ACC_IMPLEMENT_TRAITS = 0x400000
# ZEND_FETCH_CLASS_TRAIT = 14
#
# zend_vm_execute.h
# - not sure whether the handler initialization (ZEND_ADD_TRAIT_SPEC_HANDLER,
# ZEND_BIND_TRAITS_SPEC_HANDLER) is correct, maybe it should be more selective
#
# zend_compile.c
# - refactored do_inherit_method_check
# split into do_inherit_method_check and do_inheritance_check_on_method
# - added helper functions use a '_' as prefix and are not mentioned in the
# headers
# - _copy_functions
# prepare hash-maps of functions which should be merged into a class
# here the aliases are handled
# - _merge_functions
# builds a hash-table of the methods which need to be added to a class
# does the conflict detection
# - reused php_runkit_function_copy_ctor
# - it is not identical with the original code anymore, needed to update it
# think I fixed some bugs, not sure whether all have been reported back to runkit
# - has to be renamed, left the name for the moment, to make its origin obvious
# - here might be optimization potential
# - not sure whether everything needs to be copied
# - copying the literals might be broken
# - added it since the literals array is freed by efree and gave problems
# with doubled frees
# - all immutable parts of the zend_op array should not be copied
# - am not sure which parts are immutable
# - and not sure how to avoid doubled frees on the same arrays on shutdown
# - _merge_functions_to_class
# does the final merging with the target class to handle inherited
# and overridden methods
# - small helper for NULL terminated lists
# zend_init_list, zend_add_to_list
#
# zend_language_parser.y
# - reused class definition for traits
# - there should be something with regard to properties
# - if they get explicitly defined, it might be worthwhile to
# check that there are no collisions with other traits in a composition
# (however, I would not introduce elaborate language features to control that
# but a notice for such conflicts might be nice to the developers)
2010-04-23 06:05:56 +08:00
;
trait_modifiers:
/* empty */ { Z_LVAL($$.u.constant) = 0x0; } /* No change of methods visibility */
| member_modifier { $$ = $1; } /* REM: Keep in mind, there are not only visibility modifiers */
;
2003-02-11 17:48:37 +08:00
method_body:
2006-05-12 05:07:39 +08:00
';' /* abstract method */ { Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; }
| '{' inner_statement_list '}' { Z_LVAL($$.u.constant) = 0; }
2003-02-11 17:48:37 +08:00
;
2002-12-09 20:10:17 +08:00
variable_modifiers:
2003-02-11 17:48:37 +08:00
non_empty_member_modifiers { $$ = $1; }
2006-05-12 05:07:39 +08:00
| T_VAR { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
2002-11-06 03:37:31 +08:00
;
2002-12-07 01:09:44 +08:00
method_modifiers:
2006-05-12 05:07:39 +08:00
/* empty */ { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
| non_empty_member_modifiers { $$ = $1; if (!(Z_LVAL($$.u.constant) & ZEND_ACC_PPP_MASK)) { Z_LVAL($$.u.constant) |= ZEND_ACC_PUBLIC; } }
2002-06-29 23:38:40 +08:00
;
1999-04-08 02:10:10 +08:00
2003-02-11 17:48:37 +08:00
non_empty_member_modifiers:
member_modifier { $$ = $1; }
2006-05-12 05:07:39 +08:00
| non_empty_member_modifiers member_modifier { Z_LVAL($$.u.constant) = zend_do_verify_access_types(&$1, &$2); }
1999-04-08 02:10:10 +08:00
;
2003-02-11 17:48:37 +08:00
member_modifier:
2006-05-12 05:07:39 +08:00
T_PUBLIC { Z_LVAL($$.u.constant) = ZEND_ACC_PUBLIC; }
| T_PROTECTED { Z_LVAL($$.u.constant) = ZEND_ACC_PROTECTED; }
| T_PRIVATE { Z_LVAL($$.u.constant) = ZEND_ACC_PRIVATE; }
| T_STATIC { Z_LVAL($$.u.constant) = ZEND_ACC_STATIC; }
| T_ABSTRACT { Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; }
| T_FINAL { Z_LVAL($$.u.constant) = ZEND_ACC_FINAL; }
2002-12-07 01:09:44 +08:00
;
class_variable_declaration:
2003-02-10 20:46:58 +08:00
class_variable_declaration ',' T_VARIABLE { zend_do_declare_property(&$3, NULL, CG(access_type) TSRMLS_CC); }
| class_variable_declaration ',' T_VARIABLE '=' static_scalar { zend_do_declare_property(&$3, &$5, CG(access_type) TSRMLS_CC); }
| T_VARIABLE { zend_do_declare_property(&$1, NULL, CG(access_type) TSRMLS_CC); }
| T_VARIABLE '=' static_scalar { zend_do_declare_property(&$1, &$3, CG(access_type) TSRMLS_CC); }
2001-11-27 02:05:01 +08:00
;
1999-08-19 23:15:34 +08:00
2002-07-07 00:48:13 +08:00
class_constant_declaration:
2003-10-29 07:44:23 +08:00
class_constant_declaration ',' T_STRING '=' static_scalar { zend_do_declare_class_constant(&$3, &$5 TSRMLS_CC); }
| T_CONST T_STRING '=' static_scalar { zend_do_declare_class_constant(&$2, &$4 TSRMLS_CC); }
2001-12-01 00:29:47 +08:00
;
2006-05-12 05:07:39 +08:00
echo_expr_list:
2002-12-07 01:09:44 +08:00
echo_expr_list ',' expr { zend_do_echo(&$3 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| expr { zend_do_echo(&$1 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
for_expr:
2006-05-12 05:07:39 +08:00
/* empty */ { $$.op_type = IS_CONST; Z_TYPE($$.u.constant) = IS_BOOL; Z_LVAL($$.u.constant) = 1; }
2000-07-03 00:00:00 +08:00
| non_empty_for_expr { $$ = $1; }
1999-08-19 23:15:34 +08:00
;
non_empty_for_expr:
2001-07-28 18:51:54 +08:00
non_empty_for_expr ',' { zend_do_free(&$1 TSRMLS_CC); } expr { $$ = $4; }
2000-07-03 00:06:45 +08:00
| expr { $$ = $1; }
1999-04-08 02:10:10 +08:00
;
2011-11-06 21:25:45 +08:00
chaining_method_or_property:
chaining_method_or_property variable_property { $$.EA = $2.EA; }
| variable_property { $$.EA = $1.EA; }
;
chaining_dereference:
chaining_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| '[' dim_offset ']' { zend_do_pop_object(&$1 TSRMLS_CC); fetch_array_dim(&$$, &$1, &$2 TSRMLS_CC); }
;
chaining_instance_call:
chaining_dereference { zend_do_push_object(&$1 TSRMLS_CC); } chaining_method_or_property { $$ = $3; }
| chaining_dereference { zend_do_push_object(&$1 TSRMLS_CC); $$ = $1; }
| chaining_method_or_property { $$ = $1; }
;
instance_call:
/* empty */ { $$ = $0; }
| { zend_do_push_object(&$0 TSRMLS_CC); zend_do_begin_variable_parse(TSRMLS_C); }
chaining_instance_call { zend_do_pop_object(&$$ TSRMLS_CC); zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC); }
;
new_expr:
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);}
;
2006-05-12 05:07:39 +08:00
expr_without_variable:
2001-07-28 18:51:54 +08:00
T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 TSRMLS_CC); }
2007-12-28 21:22:00 +08:00
| variable '=' expr { zend_check_writable_variable(&$1); zend_do_assign(&$$, &$1, &$3 TSRMLS_CC); }
2008-05-07 20:04:39 +08:00
| 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); }
2010-04-20 18:57:45 +08:00
| 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); }
2004-02-02 20:28:19 +08:00
| T_CLONE expr { zend_do_clone(&$$, &$2 TSRMLS_CC); }
2008-05-07 20:04:39 +08:00
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
| 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); }
2002-03-20 03:09:53 +08:00
| rw_variable T_INC { zend_do_post_incdec(&$$, &$1, ZEND_POST_INC TSRMLS_CC); }
| T_INC rw_variable { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_INC TSRMLS_CC); }
| rw_variable T_DEC { zend_do_post_incdec(&$$, &$1, ZEND_POST_DEC TSRMLS_CC); }
| T_DEC rw_variable { zend_do_pre_incdec(&$$, &$2, ZEND_PRE_DEC TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| expr T_BOOLEAN_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
2006-05-12 05:07:39 +08:00
| expr T_BOOLEAN_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| expr T_LOGICAL_OR { zend_do_boolean_or_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_or_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
| expr T_LOGICAL_AND { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } expr { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
| expr T_LOGICAL_XOR expr { zend_do_binary_op(ZEND_BOOL_XOR, &$$, &$1, &$3 TSRMLS_CC); }
| expr '|' expr { zend_do_binary_op(ZEND_BW_OR, &$$, &$1, &$3 TSRMLS_CC); }
| expr '&' expr { zend_do_binary_op(ZEND_BW_AND, &$$, &$1, &$3 TSRMLS_CC); }
| expr '^' expr { zend_do_binary_op(ZEND_BW_XOR, &$$, &$1, &$3 TSRMLS_CC); }
2001-08-11 23:56:40 +08:00
| expr '.' expr { zend_do_binary_op(ZEND_CONCAT, &$$, &$1, &$3 TSRMLS_CC); }
| expr '+' expr { zend_do_binary_op(ZEND_ADD, &$$, &$1, &$3 TSRMLS_CC); }
| expr '-' expr { zend_do_binary_op(ZEND_SUB, &$$, &$1, &$3 TSRMLS_CC); }
| expr '*' expr { zend_do_binary_op(ZEND_MUL, &$$, &$1, &$3 TSRMLS_CC); }
| expr '/' expr { zend_do_binary_op(ZEND_DIV, &$$, &$1, &$3 TSRMLS_CC); }
| expr '%' expr { zend_do_binary_op(ZEND_MOD, &$$, &$1, &$3 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| expr T_SL expr { zend_do_binary_op(ZEND_SL, &$$, &$1, &$3 TSRMLS_CC); }
| expr T_SR expr { zend_do_binary_op(ZEND_SR, &$$, &$1, &$3 TSRMLS_CC); }
2008-08-30 01:54:29 +08:00
| '+' 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); } }
| '-' 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); } }
2001-07-28 18:51:54 +08:00
| '!' expr { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$2 TSRMLS_CC); }
| '~' expr { zend_do_unary_op(ZEND_BW_NOT, &$$, &$2 TSRMLS_CC); }
| expr T_IS_IDENTICAL expr { zend_do_binary_op(ZEND_IS_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
| expr T_IS_NOT_IDENTICAL expr { zend_do_binary_op(ZEND_IS_NOT_IDENTICAL, &$$, &$1, &$3 TSRMLS_CC); }
| expr T_IS_EQUAL expr { zend_do_binary_op(ZEND_IS_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
| expr T_IS_NOT_EQUAL expr { zend_do_binary_op(ZEND_IS_NOT_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
| expr '<' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$1, &$3 TSRMLS_CC); }
| expr T_IS_SMALLER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$1, &$3 TSRMLS_CC); }
| expr '>' expr { zend_do_binary_op(ZEND_IS_SMALLER, &$$, &$3, &$1 TSRMLS_CC); }
| expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); }
2003-06-22 18:50:43 +08:00
| expr T_INSTANCEOF class_name_reference { zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); }
2012-07-22 03:05:46 +08:00
| parenthesis_expr { $$ = $1; }
2011-11-06 21:25:45 +08:00
| new_expr { $$ = $1; }
| '(' new_expr ')' { $$ = $2; } instance_call { $$ = $5; }
2001-07-28 18:51:54 +08:00
| expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
expr { zend_do_qm_false(&$$, &$7, &$2, &$5 TSRMLS_CC); }
2007-11-21 17:41:35 +08:00
| expr '?' ':' { zend_do_jmp_set(&$1, &$2, &$3 TSRMLS_CC); }
expr { zend_do_jmp_set_else(&$$, &$5, &$2, &$3 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
| internal_functions_in_yacc { $$ = $1; }
2001-07-28 18:51:54 +08:00
| T_INT_CAST expr { zend_do_cast(&$$, &$2, IS_LONG TSRMLS_CC); }
| T_DOUBLE_CAST expr { zend_do_cast(&$$, &$2, IS_DOUBLE TSRMLS_CC); }
2006-05-12 05:07:39 +08:00
| T_STRING_CAST expr { zend_do_cast(&$$, &$2, IS_STRING TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| T_ARRAY_CAST expr { zend_do_cast(&$$, &$2, IS_ARRAY TSRMLS_CC); }
| T_OBJECT_CAST expr { zend_do_cast(&$$, &$2, IS_OBJECT TSRMLS_CC); }
| T_BOOL_CAST expr { zend_do_cast(&$$, &$2, IS_BOOL TSRMLS_CC); }
| T_UNSET_CAST expr { zend_do_cast(&$$, &$2, IS_NULL TSRMLS_CC); }
| T_EXIT exit_expr { zend_do_exit(&$$, &$2 TSRMLS_CC); }
| '@' { zend_do_begin_silence(&$1 TSRMLS_CC); } expr { zend_do_end_silence(&$1 TSRMLS_CC); $$ = $3; }
1999-04-08 02:10:10 +08:00
| scalar { $$ = $1; }
2012-04-15 11:40:38 +08:00
| combined_scalar_offset { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); }
| combined_scalar { $$ = $1; }
2008-07-26 23:30:28 +08:00
| '`' backticks_expr '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); }
2012-07-22 03:05:46 +08:00
| T_YIELD { zend_do_yield(&$$, NULL, NULL, 0 TSRMLS_CC); }
2012-07-20 06:49:50 +08:00
| function is_reference { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, 0 TSRMLS_CC); }
'(' parameter_list ')' lexical_vars
'{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $3; }
| T_STATIC function is_reference { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); }
'(' parameter_list ')' lexical_vars
'{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $4; }
2008-07-14 17:49:03 +08:00
;
2012-07-22 03:05:46 +08:00
yield_expr:
T_YIELD expr_without_variable { zend_do_yield(&$$, &$2, NULL, 0 TSRMLS_CC); }
| T_YIELD variable { zend_do_yield(&$$, &$2, NULL, 1 TSRMLS_CC); }
| T_YIELD expr T_DOUBLE_ARROW expr_without_variable { zend_do_yield(&$$, &$4, &$2, 0 TSRMLS_CC); }
| T_YIELD expr T_DOUBLE_ARROW variable { zend_do_yield(&$$, &$4, &$2, 1 TSRMLS_CC); }
;
2012-04-15 11:40:38 +08:00
combined_scalar_offset:
combined_scalar '[' dim_offset ']' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| combined_scalar_offset '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
2012-07-26 00:29:39 +08:00
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']' { $1.EA = 0; zend_do_begin_variable_parse(TSRMLS_C); fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
2012-04-15 11:40:38 +08:00
combined_scalar:
T_ARRAY '(' array_pair_list ')' { $$ = $3; }
| '[' array_pair_list ']' { $$ = $2; }
2008-07-14 17:49:03 +08:00
function:
2010-04-20 18:57:45 +08:00
T_FUNCTION { $$.u.op.opline_num = CG(zend_lineno); }
2008-07-14 17:49:03 +08:00
;
lexical_vars:
2008-08-30 01:54:29 +08:00
/* empty */
2008-07-14 17:49:03 +08:00
| T_USE '(' lexical_var_list ')'
;
lexical_var_list:
lexical_var_list ',' T_VARIABLE { zend_do_fetch_lexical_variable(&$3, 0 TSRMLS_CC); }
| lexical_var_list ',' '&' T_VARIABLE { zend_do_fetch_lexical_variable(&$4, 1 TSRMLS_CC); }
| T_VARIABLE { zend_do_fetch_lexical_variable(&$1, 0 TSRMLS_CC); }
| '&' T_VARIABLE { zend_do_fetch_lexical_variable(&$2, 1 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
1999-12-16 04:15:32 +08:00
function_call:
2012-07-22 03:05:46 +08:00
namespace_name { $$.u.op.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); }
function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$3, 0, $2.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
| T_NAMESPACE T_NS_SEPARATOR namespace_name { $1.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$1.u.constant); zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC); $$.u.op.opline_num = zend_do_begin_function_call(&$1, 0 TSRMLS_CC); }
function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$5, 0, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
| T_NS_SEPARATOR namespace_name { $$.u.op.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
function_call_parameter_list { zend_do_end_function_call(&$2, &$$, &$4, 0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_name { $$.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
function_call_parameter_list { zend_do_end_function_call($4.u.op.opline_num?NULL:&$3, &$$, &$5, $4.u.op.opline_num, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
| 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); }
function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
| 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); }
function_call_parameter_list { zend_do_end_function_call(NULL, &$$, &$5, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
| 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); }
function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$3, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
1999-12-16 04:15:32 +08:00
;
2007-11-12 06:11:25 +08:00
class_name:
2008-11-04 23:58:55 +08:00
T_STATIC { $$.op_type = IS_CONST; ZVAL_STRINGL(&$$.u.constant, "static", sizeof("static")-1, 1);}
| namespace_name { $$ = $1; }
| T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); }
2008-11-07 18:51:26 +08:00
| 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; }
2007-11-12 06:11:25 +08:00
;
fully_qualified_class_name:
2008-11-04 23:58:55 +08:00
namespace_name { $$ = $1; }
| T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); }
2008-11-08 19:00:23 +08:00
| 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; }
2001-12-07 01:23:08 +08:00
;
2007-11-12 06:11:25 +08:00
2003-06-22 18:50:43 +08:00
class_name_reference:
2007-11-12 06:11:25 +08:00
class_name { zend_do_fetch_class(&$$, &$1 TSRMLS_CC); }
2008-05-07 20:04:39 +08:00
| dynamic_class_name_reference { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class(&$$, &$1 TSRMLS_CC); }
2003-06-22 18:50:43 +08:00
;
dynamic_class_name_reference:
base_variable T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
2010-04-20 18:57:45 +08:00
object_property { zend_do_push_object(&$4 TSRMLS_CC); } dynamic_class_name_variable_properties
{ zend_do_pop_object(&$$ TSRMLS_CC); $$.EA = ZEND_PARSED_MEMBER; }
2003-06-22 18:50:43 +08:00
| base_variable { $$ = $1; }
;
dynamic_class_name_variable_properties:
dynamic_class_name_variable_properties dynamic_class_name_variable_property
| /* empty */
;
dynamic_class_name_variable_property:
2010-04-20 18:57:45 +08:00
T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); }
2001-10-30 01:19:02 +08:00
;
1999-12-16 04:15:32 +08:00
1999-04-08 02:10:10 +08:00
exit_expr:
2006-05-12 05:07:39 +08:00
/* empty */ { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
| '(' ')' { memset(&$$, 0, sizeof(znode)); $$.op_type = IS_UNUSED; }
2012-07-22 03:05:46 +08:00
| parenthesis_expr { $$ = $1; }
1999-04-08 02:10:10 +08:00
;
2008-07-26 23:30:28 +08:00
backticks_expr:
/* empty */ { ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; }
| T_ENCAPSED_AND_WHITESPACE { $$ = $1; }
| encaps_list { $$ = $1; }
;
1999-04-08 02:10:10 +08:00
ctor_arguments:
2012-07-22 03:05:46 +08:00
/* empty */ { Z_LVAL($$.u.constant) = 0; }
| function_call_parameter_list { $$ = $1; }
1999-04-08 02:10:10 +08:00
;
common_scalar:
2000-07-03 00:06:45 +08:00
T_LNUMBER { $$ = $1; }
| T_DNUMBER { $$ = $1; }
1999-04-23 07:08:42 +08:00
| T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
2000-07-03 00:06:45 +08:00
| T_LINE { $$ = $1; }
| T_FILE { $$ = $1; }
2008-02-12 08:21:15 +08:00
| T_DIR { $$ = $1; }
2011-08-01 01:39:30 +08:00
| T_TRAIT_C { $$ = $1; }
2004-02-27 03:59:49 +08:00
| T_METHOD_C { $$ = $1; }
2002-04-11 05:23:01 +08:00
| T_FUNC_C { $$ = $1; }
2007-09-29 03:52:53 +08:00
| T_NS_C { $$ = $1; }
2012-03-31 02:41:44 +08:00
| T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2; }
| T_START_HEREDOC T_END_HEREDOC { ZVAL_EMPTY_STRING(&$$.u.constant); INIT_PZVAL(&$$.u.constant); $$.op_type = IS_CONST; }
1999-04-08 02:10:10 +08:00
;
static_scalar: /* compile-time evaluated scalars */
common_scalar { $$ = $1; }
2013-01-19 08:00:47 +08:00
| static_class_name_scalar { $$ = $1; }
2008-11-04 23:58:55 +08:00
| namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT, 1 TSRMLS_CC); }
2008-11-12 03:45:29 +08:00
| 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); }
2008-11-08 19:00:23 +08:00
| 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); }
2008-08-30 01:54:29 +08:00
| '+' static_scalar { ZVAL_LONG(&$1.u.constant, 0); add_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
| '-' static_scalar { ZVAL_LONG(&$1.u.constant, 0); sub_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
2006-05-12 05:07:39 +08:00
| T_ARRAY '(' static_array_pair_list ')' { $$ = $3; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
2011-07-24 04:23:21 +08:00
| '[' static_array_pair_list ']' { $$ = $2; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
2003-06-22 05:56:44 +08:00
| static_class_constant { $$ = $1; }
2012-01-17 16:09:13 +08:00
| T_CLASS_C { $$ = $1; }
2003-06-15 21:58:50 +08:00
;
static_class_constant:
2008-11-12 03:45:29 +08:00
class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_CT, 0 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
scalar:
2008-11-04 23:58:55 +08:00
T_STRING_VARNAME { $$ = $1; }
2013-01-19 08:00:47 +08:00
| class_name_scalar { $$ = $1; }
2008-11-04 23:58:55 +08:00
| class_constant { $$ = $1; }
| namespace_name { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC); }
2008-11-12 03:45:29 +08:00
| 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); }
2008-11-08 19:00:23 +08:00
| 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); }
2000-07-03 00:06:45 +08:00
| common_scalar { $$ = $1; }
1999-04-08 02:10:10 +08:00
| '"' encaps_list '"' { $$ = $2; }
2012-03-31 02:41:44 +08:00
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; }
2012-01-17 16:09:13 +08:00
| T_CLASS_C { if (Z_TYPE($1.u.constant) == IS_CONSTANT) {zend_do_fetch_constant(&$$, NULL, &$1, ZEND_RT, 1 TSRMLS_CC);} else {$$ = $1;} }
1999-04-08 02:10:10 +08:00
;
static_array_pair_list:
2000-07-03 00:00:00 +08:00
/* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); }
2000-03-14 23:37:15 +08:00
| non_empty_static_array_pair_list possible_comma { $$ = $1; }
1999-04-08 02:10:10 +08:00
;
2000-03-14 23:37:15 +08:00
possible_comma:
/* empty */
| ','
;
1999-04-08 02:10:10 +08:00
non_empty_static_array_pair_list:
2000-11-03 03:31:21 +08:00
non_empty_static_array_pair_list ',' static_scalar T_DOUBLE_ARROW static_scalar { zend_do_add_static_array_element(&$$, &$3, &$5); }
| non_empty_static_array_pair_list ',' static_scalar { zend_do_add_static_array_element(&$$, NULL, &$3); }
| 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); }
| static_scalar { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); array_init(&$$.u.constant); zend_do_add_static_array_element(&$$, NULL, &$1); }
1999-04-08 02:10:10 +08:00
;
expr:
2002-03-20 03:09:53 +08:00
r_variable { $$ = $1; }
2001-12-14 06:21:50 +08:00
| expr_without_variable { $$ = $1; }
1999-04-08 02:10:10 +08:00
;
2012-07-22 03:05:46 +08:00
parenthesis_expr:
'(' expr ')' { $$ = $2; }
| '(' yield_expr ')' { $$ = $2; }
;
1999-04-08 02:10:10 +08:00
2002-03-20 03:09:53 +08:00
r_variable:
2008-05-07 20:04:39 +08:00
variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$ = $1; }
1999-04-08 02:10:10 +08:00
;
2002-03-20 03:09:53 +08:00
w_variable:
2008-05-07 20:04:39 +08:00
variable { zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); $$ = $1;
2008-02-03 22:32:48 +08:00
zend_check_writable_variable(&$1); }
1999-04-08 02:10:10 +08:00
;
2002-03-20 03:09:53 +08:00
rw_variable:
2008-05-07 20:04:39 +08:00
variable { zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); $$ = $1;
2008-02-03 22:32:48 +08:00
zend_check_writable_variable(&$1); }
1999-04-08 02:10:10 +08:00
;
2002-03-18 03:13:46 +08:00
variable:
2003-06-22 18:50:43 +08:00
base_variable_with_function_calls T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
2001-12-17 03:18:19 +08:00
object_property { zend_do_push_object(&$4 TSRMLS_CC); } method_or_not variable_properties
2010-04-20 18:57:45 +08:00
{ zend_do_pop_object(&$$ TSRMLS_CC); $$.EA = $1.EA | ($7.EA ? $7.EA : $6.EA); }
2003-06-22 18:50:43 +08:00
| base_variable_with_function_calls { $$ = $1; }
2001-09-07 22:46:12 +08:00
;
2001-12-14 06:21:50 +08:00
variable_properties:
2010-04-20 18:57:45 +08:00
variable_properties variable_property { $$.EA = $2.EA; }
| /* empty */ { $$.EA = 0; }
2001-09-07 22:46:12 +08:00
;
2001-12-14 06:21:50 +08:00
2001-09-07 22:46:12 +08:00
variable_property:
2010-04-20 18:57:45 +08:00
T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); } method_or_not { $$.EA = $4.EA; }
1999-04-08 02:10:10 +08:00
;
2010-06-08 08:05:29 +08:00
array_method_dereference:
array_method_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
2010-08-25 17:14:36 +08:00
| method '[' dim_offset ']' { $1.EA = ZEND_PARSED_METHOD_CALL; fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
2010-06-08 08:05:29 +08:00
;
method:
2012-07-22 03:05:46 +08:00
{ zend_do_pop_object(&$$ TSRMLS_CC); zend_do_begin_method_call(&$$ TSRMLS_CC); }
function_call_parameter_list { zend_do_end_function_call(&$1, &$$, &$2, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
2010-06-08 08:05:29 +08:00
;
2011-05-15 08:36:13 +08:00
method_or_not:
2010-08-25 17:14:36 +08:00
method { $$ = $1; $$.EA = ZEND_PARSED_METHOD_CALL; zend_do_push_object(&$$ TSRMLS_CC); }
2010-06-13 00:11:10 +08:00
| array_method_dereference { $$ = $1; zend_do_push_object(&$$ TSRMLS_CC); }
2010-04-20 18:57:45 +08:00
| /* empty */ { $$.EA = ZEND_PARSED_MEMBER; }
2001-12-14 06:21:50 +08:00
;
1999-04-08 02:10:10 +08:00
2002-03-20 03:09:53 +08:00
variable_without_objects:
1999-04-08 02:10:10 +08:00
reference_variable { $$ = $1; }
2001-07-28 18:51:54 +08:00
| simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
2001-12-14 06:21:50 +08:00
static_member:
2007-11-12 06:11:25 +08:00
class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
2007-09-27 08:32:40 +08:00
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
2001-12-14 06:21:50 +08:00
;
2007-09-27 08:32:40 +08:00
variable_class_name:
2008-05-07 20:04:39 +08:00
reference_variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$=$1;; }
2007-09-27 08:32:40 +08:00
;
2001-12-14 06:21:50 +08:00
2010-06-08 08:05:29 +08:00
array_function_dereference:
array_function_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
2011-05-15 08:36:13 +08:00
| function_call { zend_do_begin_variable_parse(TSRMLS_C); $1.EA = ZEND_PARSED_FUNCTION_CALL; }
2010-06-08 08:05:29 +08:00
'[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$4 TSRMLS_CC); }
;
2003-06-22 18:50:43 +08:00
base_variable_with_function_calls:
2010-06-08 08:05:29 +08:00
base_variable { $$ = $1; }
| array_function_dereference { $$ = $1; }
2010-04-20 18:57:45 +08:00
| function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; $$.EA = ZEND_PARSED_FUNCTION_CALL; }
2003-06-22 18:50:43 +08:00
;
base_variable:
2010-04-20 18:57:45 +08:00
reference_variable { $$ = $1; $$.EA = ZEND_PARSED_VARIABLE; }
| simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); $$.EA = ZEND_PARSED_VARIABLE; }
| static_member { $$ = $1; $$.EA = ZEND_PARSED_STATIC_MEMBER; }
2001-12-14 06:21:50 +08:00
;
2006-05-12 05:07:39 +08:00
1999-04-08 02:10:10 +08:00
reference_variable:
2001-07-28 18:51:54 +08:00
reference_variable '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| reference_variable '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
2002-01-21 04:42:15 +08:00
| compound_variable { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
2006-05-12 05:07:39 +08:00
1999-04-08 02:10:10 +08:00
compound_variable:
2000-07-03 00:06:45 +08:00
T_VARIABLE { $$ = $1; }
1999-04-08 02:10:10 +08:00
| '$' '{' expr '}' { $$ = $3; }
;
dim_offset:
/* empty */ { $$.op_type = IS_UNUSED; }
| expr { $$ = $1; }
;
object_property:
2000-02-01 03:18:07 +08:00
object_dim_list { $$ = $1; }
2008-05-07 20:04:39 +08:00
| 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);}
1999-04-08 02:10:10 +08:00
;
object_dim_list:
2001-07-28 18:51:54 +08:00
object_dim_list '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
| object_dim_list '{' expr '}' { fetch_string_offset(&$$, &$1, &$3 TSRMLS_CC); }
| variable_name { znode tmp_znode; zend_do_pop_object(&tmp_znode TSRMLS_CC); zend_do_fetch_property(&$$, &tmp_znode, &$1 TSRMLS_CC);}
2000-01-29 18:16:04 +08:00
;
2000-01-16 01:17:32 +08:00
variable_name:
2000-07-03 00:06:45 +08:00
T_STRING { $$ = $1; }
2000-01-16 01:17:32 +08:00
| '{' expr '}' { $$ = $2; }
1999-04-08 02:10:10 +08:00
;
simple_indirect_reference:
2006-05-12 05:07:39 +08:00
'$' { Z_LVAL($$.u.constant) = 1; }
| simple_indirect_reference '$' { Z_LVAL($$.u.constant)++; }
1999-04-08 02:10:10 +08:00
;
assignment_list:
assignment_list ',' assignment_list_element
| assignment_list_element
;
assignment_list_element:
2002-03-18 03:13:46 +08:00
variable { zend_do_add_list_element(&$1 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| T_LIST '(' { zend_do_new_list_begin(TSRMLS_C); } assignment_list ')' { zend_do_new_list_end(TSRMLS_C); }
| /* empty */ { zend_do_add_list_element(NULL TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
array_pair_list:
2001-07-28 18:51:54 +08:00
/* empty */ { zend_do_init_array(&$$, NULL, NULL, 0 TSRMLS_CC); }
2000-03-14 23:37:15 +08:00
| non_empty_array_pair_list possible_comma { $$ = $1; }
1999-04-08 02:10:10 +08:00
;
non_empty_array_pair_list:
2001-07-28 18:51:54 +08:00
non_empty_array_pair_list ',' expr T_DOUBLE_ARROW expr { zend_do_add_array_element(&$$, &$5, &$3, 0 TSRMLS_CC); }
| non_empty_array_pair_list ',' expr { zend_do_add_array_element(&$$, &$3, NULL, 0 TSRMLS_CC); }
| expr T_DOUBLE_ARROW expr { zend_do_init_array(&$$, &$3, &$1, 0 TSRMLS_CC); }
| expr { zend_do_init_array(&$$, &$1, NULL, 0 TSRMLS_CC); }
2002-03-20 03:09:53 +08:00
| non_empty_array_pair_list ',' expr T_DOUBLE_ARROW '&' w_variable { zend_do_add_array_element(&$$, &$6, &$3, 1 TSRMLS_CC); }
| non_empty_array_pair_list ',' '&' w_variable { zend_do_add_array_element(&$$, &$4, NULL, 1 TSRMLS_CC); }
| expr T_DOUBLE_ARROW '&' w_variable { zend_do_init_array(&$$, &$4, &$1, 1 TSRMLS_CC); }
| '&' w_variable { zend_do_init_array(&$$, &$2, NULL, 1 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
encaps_list:
2008-05-07 20:04:39 +08:00
encaps_list encaps_var { zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC); zend_do_add_variable(&$$, &$1, &$2 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| encaps_list T_ENCAPSED_AND_WHITESPACE { zend_do_add_string(&$$, &$1, &$2 TSRMLS_CC); }
2008-07-26 23:30:28 +08:00
| encaps_var { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_add_variable(&$$, NULL, &$1 TSRMLS_CC); }
| 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); }
1999-04-08 02:10:10 +08:00
;
encaps_var:
2002-01-21 04:42:15 +08:00
T_VARIABLE { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
| T_VARIABLE '[' { zend_do_begin_variable_parse(TSRMLS_C); } encaps_var_offset ']' { fetch_array_begin(&$$, &$1, &$4 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| 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); }
| T_DOLLAR_OPEN_CURLY_BRACES expr '}' { zend_do_begin_variable_parse(TSRMLS_C); fetch_simple_variable(&$$, &$2, 1 TSRMLS_CC); }
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' { zend_do_begin_variable_parse(TSRMLS_C); fetch_array_begin(&$$, &$2, &$4 TSRMLS_CC); }
2002-03-20 03:09:53 +08:00
| T_CURLY_OPEN variable '}' { $$ = $2; }
1999-04-08 02:10:10 +08:00
;
encaps_var_offset:
2000-07-03 00:06:45 +08:00
T_STRING { $$ = $1; }
1999-04-23 07:08:42 +08:00
| T_NUM_STRING { $$ = $1; }
2001-07-28 18:51:54 +08:00
| T_VARIABLE { fetch_simple_variable(&$$, &$1, 1 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
internal_functions_in_yacc:
2001-03-20 03:31:14 +08:00
T_ISSET '(' isset_variables ')' { $$ = $3; }
2002-03-18 03:13:46 +08:00
| T_EMPTY '(' variable ')' { zend_do_isset_or_isempty(ZEND_ISEMPTY, &$$, &$3 TSRMLS_CC); }
2012-04-12 17:54:52 +08:00
| T_EMPTY '(' expr_without_variable ')' { zend_do_unary_op(ZEND_BOOL_NOT, &$$, &$3 TSRMLS_CC); }
2001-07-28 18:51:54 +08:00
| T_INCLUDE expr { zend_do_include_or_eval(ZEND_INCLUDE, &$$, &$2 TSRMLS_CC); }
| T_INCLUDE_ONCE expr { zend_do_include_or_eval(ZEND_INCLUDE_ONCE, &$$, &$2 TSRMLS_CC); }
| T_EVAL '(' expr ')' { zend_do_include_or_eval(ZEND_EVAL, &$$, &$3 TSRMLS_CC); }
| T_REQUIRE expr { zend_do_include_or_eval(ZEND_REQUIRE, &$$, &$2 TSRMLS_CC); }
| T_REQUIRE_ONCE expr { zend_do_include_or_eval(ZEND_REQUIRE_ONCE, &$$, &$2 TSRMLS_CC); }
1999-04-08 02:10:10 +08:00
;
2001-03-20 03:31:14 +08:00
isset_variables:
2012-04-12 17:54:52 +08:00
isset_variable { $$ = $1; }
| isset_variables ',' { zend_do_boolean_and_begin(&$1, &$2 TSRMLS_CC); } isset_variable { zend_do_boolean_and_end(&$$, &$1, &$4, &$2 TSRMLS_CC); }
;
isset_variable:
variable { zend_do_isset_or_isempty(ZEND_ISSET, &$$, &$1 TSRMLS_CC); }
| expr_without_variable { zend_error(E_COMPILE_ERROR, "Cannot use isset() on the result of an expression (you can use \"null !== expression\" instead)"); }
2006-05-12 05:07:39 +08:00
;
1999-04-08 02:10:10 +08:00
2003-06-02 20:13:11 +08:00
class_constant:
2008-11-12 03:45:29 +08:00
class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT, 0 TSRMLS_CC); }
2007-09-29 03:52:53 +08:00
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT, 0 TSRMLS_CC); }
2003-03-10 04:53:57 +08:00
;
2013-01-19 08:00:47 +08:00
static_class_name_scalar:
class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS { zend_do_resolve_class_name(&$$, &$1, 1 TSRMLS_CC); }
;
class_name_scalar:
class_name T_PAAMAYIM_NEKUDOTAYIM T_CLASS { zend_do_resolve_class_name(&$$, &$1, 0 TSRMLS_CC); }
;
1999-04-08 02:10:10 +08:00
%%
2011-06-24 07:00:53 +08:00
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
quotes and backslashes, so that it's suitable for yyerror. The
heuristic is that double-quoting is unnecessary unless the string
contains an apostrophe, a comma, or backslash (other than
backslash-backslash). YYSTR is taken from yytname. If YYRES is
null, do not copy; instead, return the length of what the result
would have been. */
static YYSIZE_T zend_yytnamerr(char *yyres, const char *yystr)
{
if (!yyres) {
return yystrlen(yystr);
}
{
TSRMLS_FETCH();
if (CG(parse_error) == 0) {
2011-06-24 08:38:53 +08:00
char buffer[120];
const unsigned char *end, *str, *tok1 = NULL, *tok2 = NULL;
2011-06-24 07:00:53 +08:00
unsigned int len = 0, toklen = 0, yystr_len;
CG(parse_error) = 1;
if (LANG_SCNG(yy_text)[0] == 0 &&
LANG_SCNG(yy_leng) == 1 &&
2012-06-26 18:42:33 +08:00
memcmp(yystr, "\"end of file\"", sizeof("\"end of file\"") - 1) == 0) {
2011-06-24 08:38:53 +08:00
yystpcpy(yyres, "end of file");
return sizeof("end of file")-1;
2011-06-24 07:00:53 +08:00
}
str = LANG_SCNG(yy_text);
end = memchr(str, '\n', LANG_SCNG(yy_leng));
yystr_len = yystrlen(yystr);
if ((tok1 = memchr(yystr, '(', yystr_len)) != NULL
&& (tok2 = zend_memrchr(yystr, ')', yystr_len)) != NULL) {
toklen = (tok2 - tok1) + 1;
} else {
tok1 = tok2 = NULL;
toklen = 0;
}
if (end == NULL) {
len = LANG_SCNG(yy_leng) > 30 ? 30 : LANG_SCNG(yy_leng);
} else {
len = (end - str) > 30 ? 30 : (end - str);
}
if (toklen) {
snprintf(buffer, sizeof(buffer), "'%.*s' %.*s", len, str, toklen, tok1);
} else {
snprintf(buffer, sizeof(buffer), "'%.*s'", len, str);
}
2011-06-24 08:38:53 +08:00
yystpcpy(yyres, buffer);
return len + (toklen ? toklen + 1 : 0) + 2;
2011-06-24 07:00:53 +08:00
}
}
if (*yystr == '"') {
YYSIZE_T yyn = 0;
const char *yyp = yystr;
for (; *++yyp != '"'; ++yyn) {
yyres[yyn] = *yyp;
}
yyres[yyn] = '\0';
return yyn;
}
2011-06-24 08:38:53 +08:00
yystpcpy(yyres, yystr);
return strlen(yystr);
2011-06-24 07:00:53 +08:00
}
2003-02-01 09:49:15 +08:00
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
*/