1999-04-08 02:10:10 +08:00
|
|
|
%{
|
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2018-01-02 12:57:58 +08:00
|
|
|
| Copyright (c) 1998-2018 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> |
|
2014-07-27 19:25:32 +08:00
|
|
|
| Nikita Popov <nikic@php.net> |
|
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"
|
2015-04-05 19:50:35 +08:00
|
|
|
#include "zend_language_scanner.h"
|
2017-09-24 21:24:51 +08:00
|
|
|
#include "zend_exceptions.h"
|
2005-06-05 00:16:19 +08:00
|
|
|
|
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
|
2014-07-27 18:45:38 +08:00
|
|
|
#define YYSTYPE zend_parser_stack_elem
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-10-29 02:18:47 +08:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define YYMALLOC malloc
|
|
|
|
#define YYFREE free
|
|
|
|
#endif
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
%}
|
|
|
|
|
2016-08-05 00:14:41 +08:00
|
|
|
%pure-parser
|
2015-05-26 02:26:57 +08:00
|
|
|
%expect 0
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2013-03-25 23:48:21 +08:00
|
|
|
%code requires {
|
|
|
|
}
|
|
|
|
|
2014-08-27 02:42:25 +08:00
|
|
|
%destructor { zend_ast_destroy($$); } <ast>
|
2018-05-28 21:27:12 +08:00
|
|
|
%destructor { if ($$) zend_string_release_ex($$, 0); } <str>
|
2014-08-22 06:40:07 +08:00
|
|
|
|
2000-08-10 03:22:35 +08:00
|
|
|
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
|
2014-08-22 06:40:07 +08:00
|
|
|
%left ','
|
|
|
|
%left T_LOGICAL_OR
|
|
|
|
%left T_LOGICAL_XOR
|
|
|
|
%left T_LOGICAL_AND
|
|
|
|
%right T_PRINT
|
|
|
|
%right T_YIELD
|
2014-12-08 05:58:14 +08:00
|
|
|
%right T_DOUBLE_ARROW
|
2015-03-07 07:28:12 +08:00
|
|
|
%right T_YIELD_FROM
|
2014-08-22 06:40:07 +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 T_POW_EQUAL
|
|
|
|
%left '?' ':'
|
2014-09-17 02:14:46 +08:00
|
|
|
%right T_COALESCE
|
2014-08-22 06:40:07 +08:00
|
|
|
%left T_BOOLEAN_OR
|
2015-01-03 17:22:58 +08:00
|
|
|
%left T_BOOLEAN_AND
|
2014-08-22 06:40:07 +08:00
|
|
|
%left '|'
|
|
|
|
%left '^'
|
|
|
|
%left '&'
|
2015-01-19 22:14:43 +08:00
|
|
|
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL T_SPACESHIP
|
2014-08-22 06:40:07 +08:00
|
|
|
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
|
|
|
|
%left T_SL T_SR
|
|
|
|
%left '+' '-' '.'
|
|
|
|
%left '*' '/' '%'
|
|
|
|
%right '!'
|
|
|
|
%nonassoc T_INSTANCEOF
|
|
|
|
%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 '@'
|
|
|
|
%right T_POW
|
|
|
|
%right '['
|
|
|
|
%nonassoc T_NEW T_CLONE
|
2015-05-26 18:11:07 +08:00
|
|
|
%left T_NOELSE
|
2014-08-22 06:40:07 +08:00
|
|
|
%left T_ELSEIF
|
2015-01-03 17:22:58 +08:00
|
|
|
%left T_ELSE
|
|
|
|
%left T_ENDIF
|
2014-08-22 06:40:07 +08:00
|
|
|
%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
|
|
|
|
|
|
|
|
%token <ast> T_LNUMBER "integer number (T_LNUMBER)"
|
|
|
|
%token <ast> T_DNUMBER "floating-point number (T_DNUMBER)"
|
|
|
|
%token <ast> T_STRING "identifier (T_STRING)"
|
|
|
|
%token <ast> T_VARIABLE "variable (T_VARIABLE)"
|
|
|
|
%token <ast> T_INLINE_HTML
|
|
|
|
%token <ast> T_ENCAPSED_AND_WHITESPACE "quoted-string and whitespace (T_ENCAPSED_AND_WHITESPACE)"
|
|
|
|
%token <ast> T_CONSTANT_ENCAPSED_STRING "quoted-string (T_CONSTANT_ENCAPSED_STRING)"
|
|
|
|
%token <ast> T_STRING_VARNAME "variable name (T_STRING_VARNAME)"
|
|
|
|
%token <ast> T_NUM_STRING "number (T_NUM_STRING)"
|
|
|
|
|
|
|
|
%token END 0 "end of file"
|
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)"
|
|
|
|
%token T_LOGICAL_OR "or (T_LOGICAL_OR)"
|
|
|
|
%token T_LOGICAL_XOR "xor (T_LOGICAL_XOR)"
|
|
|
|
%token T_LOGICAL_AND "and (T_LOGICAL_AND)"
|
|
|
|
%token T_PRINT "print (T_PRINT)"
|
2012-05-29 23:34:33 +08:00
|
|
|
%token T_YIELD "yield (T_YIELD)"
|
2015-03-07 07:28:12 +08:00
|
|
|
%token T_YIELD_FROM "yield from (T_YIELD_FROM)"
|
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)"
|
|
|
|
%token T_BOOLEAN_OR "|| (T_BOOLEAN_OR)"
|
|
|
|
%token T_BOOLEAN_AND "&& (T_BOOLEAN_AND)"
|
|
|
|
%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)"
|
|
|
|
%token T_IS_SMALLER_OR_EQUAL "<= (T_IS_SMALLER_OR_EQUAL)"
|
|
|
|
%token T_IS_GREATER_OR_EQUAL ">= (T_IS_GREATER_OR_EQUAL)"
|
2015-01-19 15:12:39 +08:00
|
|
|
%token T_SPACESHIP "<=> (T_SPACESHIP)"
|
2011-06-24 07:00:53 +08:00
|
|
|
%token T_SL "<< (T_SL)"
|
|
|
|
%token T_SR ">> (T_SR)"
|
|
|
|
%token T_INSTANCEOF "instanceof (T_INSTANCEOF)"
|
|
|
|
%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)"
|
|
|
|
%token T_NEW "new (T_NEW)"
|
|
|
|
%token T_CLONE "clone (T_CLONE)"
|
|
|
|
%token T_EXIT "exit (T_EXIT)"
|
|
|
|
%token T_IF "if (T_IF)"
|
|
|
|
%token T_ELSEIF "elseif (T_ELSEIF)"
|
|
|
|
%token T_ELSE "else (T_ELSE)"
|
|
|
|
%token T_ENDIF "endif (T_ENDIF)"
|
|
|
|
%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)"
|
|
|
|
%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)"
|
2014-08-27 04:47:11 +08:00
|
|
|
%token T_LINE "__LINE__ (T_LINE)"
|
|
|
|
%token T_FILE "__FILE__ (T_FILE)"
|
|
|
|
%token T_DIR "__DIR__ (T_DIR)"
|
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)"
|
2018-03-14 06:08:03 +08:00
|
|
|
%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)"
|
2011-06-24 07:00:53 +08:00
|
|
|
%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_NS_SEPARATOR "\\ (T_NS_SEPARATOR)"
|
2013-09-27 00:39:17 +08:00
|
|
|
%token T_ELLIPSIS "... (T_ELLIPSIS)"
|
2014-09-17 02:14:46 +08:00
|
|
|
%token T_COALESCE "?? (T_COALESCE)"
|
2013-11-19 15:36:06 +08:00
|
|
|
%token T_POW "** (T_POW)"
|
|
|
|
%token T_POW_EQUAL "**= (T_POW_EQUAL)"
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2015-03-22 03:10:19 +08:00
|
|
|
/* Token used to force a parse error from the lexer */
|
|
|
|
%token T_ERROR
|
|
|
|
|
2014-08-22 06:40:07 +08:00
|
|
|
%type <ast> top_statement namespace_name name statement function_declaration_statement
|
2014-12-02 02:44:07 +08:00
|
|
|
%type <ast> class_declaration_statement trait_declaration_statement
|
|
|
|
%type <ast> interface_declaration_statement interface_extends_list
|
2015-03-08 04:59:20 +08:00
|
|
|
%type <ast> group_use_declaration inline_use_declarations inline_use_declaration
|
2015-08-20 17:47:43 +08:00
|
|
|
%type <ast> mixed_group_use_declaration use_declaration unprefixed_use_declaration
|
|
|
|
%type <ast> unprefixed_use_declarations const_decl inner_statement
|
2014-08-30 00:51:58 +08:00
|
|
|
%type <ast> expr optional_expr while_statement for_statement foreach_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
%type <ast> foreach_statement declare_statement finally_statement unset_variable variable
|
2018-06-24 19:34:32 +08:00
|
|
|
%type <ast> extends_from parameter optional_type argument global_var
|
2014-08-22 06:40:07 +08:00
|
|
|
%type <ast> static_var class_statement trait_adaptation trait_precedence trait_alias
|
|
|
|
%type <ast> absolute_trait_method_reference trait_method_reference property echo_expr
|
2015-04-26 21:54:30 +08:00
|
|
|
%type <ast> new_expr anonymous_class class_name class_name_reference simple_variable
|
|
|
|
%type <ast> internal_functions_in_yacc
|
2015-03-09 13:24:50 +08:00
|
|
|
%type <ast> exit_expr scalar backticks_expr lexical_var function_call member_name property_name
|
2015-05-26 04:58:30 +08:00
|
|
|
%type <ast> variable_class_name dereferencable_scalar constant dereferencable
|
2014-08-30 00:51:58 +08:00
|
|
|
%type <ast> callable_expr callable_variable static_member new_variable
|
2016-03-26 01:18:42 +08:00
|
|
|
%type <ast> encaps_var encaps_var_offset isset_variables
|
2014-08-30 02:52:26 +08:00
|
|
|
%type <ast> top_statement_list use_declarations const_list inner_statement_list if_stmt
|
|
|
|
%type <ast> alt_if_stmt for_exprs switch_case_list global_var_list static_var_list
|
2016-05-02 06:47:08 +08:00
|
|
|
%type <ast> echo_expr_list unset_variables catch_name_list catch_list parameter_list class_statement_list
|
2014-12-02 02:44:07 +08:00
|
|
|
%type <ast> implements_list case_list if_stmt_without_else
|
2014-08-30 02:52:26 +08:00
|
|
|
%type <ast> non_empty_parameter_list argument_list non_empty_argument_list property_list
|
2015-03-09 13:24:50 +08:00
|
|
|
%type <ast> class_const_list class_const_decl name_list trait_adaptations method_body non_empty_for_exprs
|
2014-08-30 02:52:26 +08:00
|
|
|
%type <ast> ctor_arguments alt_if_stmt_without_else trait_adaptation_list lexical_vars
|
2016-04-05 06:34:42 +08:00
|
|
|
%type <ast> lexical_var_list encaps_list
|
2016-06-14 00:21:14 +08:00
|
|
|
%type <ast> array_pair non_empty_array_pair_list array_pair_list possible_array_pair
|
2016-04-29 05:26:57 +08:00
|
|
|
%type <ast> isset_variable type return_type type_expr
|
2015-03-09 13:24:50 +08:00
|
|
|
%type <ast> identifier
|
2014-08-22 06:40:07 +08:00
|
|
|
|
2014-12-02 02:44:07 +08:00
|
|
|
%type <num> returns_ref function is_reference is_variadic variable_modifiers
|
2015-05-26 02:26:57 +08:00
|
|
|
%type <num> method_modifiers non_empty_member_modifiers member_modifier
|
2016-05-13 06:40:15 +08:00
|
|
|
%type <num> class_modifiers class_modifier use_type backup_fn_flags
|
2014-08-22 06:40:07 +08:00
|
|
|
|
2014-08-27 04:30:18 +08:00
|
|
|
%type <str> backup_doc_comment
|
2014-08-22 06:40:07 +08:00
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
%% /* Rules */
|
|
|
|
|
2000-01-29 06:23:28 +08:00
|
|
|
start:
|
2014-08-30 02:52:26 +08:00
|
|
|
top_statement_list { CG(ast) = $1; }
|
2000-01-29 06:23:28 +08:00
|
|
|
;
|
|
|
|
|
2015-05-26 02:26:57 +08:00
|
|
|
reserved_non_modifiers:
|
2015-03-09 13:24:50 +08:00
|
|
|
T_INCLUDE | T_INCLUDE_ONCE | T_EVAL | T_REQUIRE | T_REQUIRE_ONCE | T_LOGICAL_OR | T_LOGICAL_XOR | T_LOGICAL_AND
|
|
|
|
| T_INSTANCEOF | T_NEW | T_CLONE | T_EXIT | T_IF | T_ELSEIF | T_ELSE | T_ENDIF | T_ECHO | T_DO | T_WHILE | T_ENDWHILE
|
|
|
|
| T_FOR | T_ENDFOR | T_FOREACH | T_ENDFOREACH | T_DECLARE | T_ENDDECLARE | T_AS | T_TRY | T_CATCH | T_FINALLY
|
|
|
|
| T_THROW | T_USE | T_INSTEADOF | T_GLOBAL | T_VAR | T_UNSET | T_ISSET | T_EMPTY | T_CONTINUE | T_GOTO
|
|
|
|
| T_FUNCTION | T_CONST | T_RETURN | T_PRINT | T_YIELD | T_LIST | T_SWITCH | T_ENDSWITCH | T_CASE | T_DEFAULT | T_BREAK
|
2015-05-26 06:17:27 +08:00
|
|
|
| T_ARRAY | T_CALLABLE | T_EXTENDS | T_IMPLEMENTS | T_NAMESPACE | T_TRAIT | T_INTERFACE | T_CLASS
|
2016-04-07 11:51:49 +08:00
|
|
|
| T_CLASS_C | T_TRAIT_C | T_FUNC_C | T_METHOD_C | T_LINE | T_FILE | T_DIR | T_NS_C
|
2015-03-09 13:24:50 +08:00
|
|
|
;
|
|
|
|
|
2015-05-26 02:26:57 +08:00
|
|
|
semi_reserved:
|
|
|
|
reserved_non_modifiers
|
|
|
|
| T_STATIC | T_ABSTRACT | T_FINAL | T_PRIVATE | T_PROTECTED | T_PUBLIC
|
|
|
|
;
|
|
|
|
|
2015-03-09 13:24:50 +08:00
|
|
|
identifier:
|
|
|
|
T_STRING { $$ = $1; }
|
2015-04-05 19:50:35 +08:00
|
|
|
| semi_reserved {
|
|
|
|
zval zv;
|
|
|
|
zend_lex_tstring(&zv);
|
|
|
|
$$ = zend_ast_create_zval(&zv);
|
|
|
|
}
|
2015-03-09 13:24:50 +08:00
|
|
|
;
|
|
|
|
|
2001-07-28 18:51:54 +08:00
|
|
|
top_statement_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
top_statement_list top_statement { $$ = zend_ast_list_add($1, $2); }
|
|
|
|
| /* empty */ { $$ = zend_ast_create_list(0, ZEND_AST_STMT_LIST); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2007-09-29 03:52:53 +08:00
|
|
|
namespace_name:
|
2014-08-30 02:52:26 +08:00
|
|
|
T_STRING { $$ = $1; }
|
|
|
|
| namespace_name T_NS_SEPARATOR T_STRING { $$ = zend_ast_append_str($1, $3); }
|
2007-09-29 03:52:53 +08:00
|
|
|
;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-07-05 05:08:05 +08:00
|
|
|
name:
|
2014-08-30 02:52:26 +08:00
|
|
|
namespace_name { $$ = $1; $$->attr = ZEND_NAME_NOT_FQ; }
|
|
|
|
| T_NAMESPACE T_NS_SEPARATOR namespace_name { $$ = $3; $$->attr = ZEND_NAME_RELATIVE; }
|
|
|
|
| T_NS_SEPARATOR namespace_name { $$ = $2; $$->attr = ZEND_NAME_FQ; }
|
2014-07-05 05:08:05 +08:00
|
|
|
;
|
|
|
|
|
1999-05-15 23:47:24 +08:00
|
|
|
top_statement:
|
2014-12-02 02:44:07 +08:00
|
|
|
statement { $$ = $1; }
|
|
|
|
| function_declaration_statement { $$ = $1; }
|
|
|
|
| class_declaration_statement { $$ = $1; }
|
|
|
|
| trait_declaration_statement { $$ = $1; }
|
|
|
|
| interface_declaration_statement { $$ = $1; }
|
2014-07-22 20:22:59 +08:00
|
|
|
| T_HALT_COMPILER '(' ')' ';'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_HALT_COMPILER,
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_ast_create_zval_from_long(zend_get_scanned_file_offset()));
|
|
|
|
zend_stop_lexing(); }
|
2014-07-22 18:45:44 +08:00
|
|
|
| T_NAMESPACE namespace_name ';'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_NAMESPACE, $2, NULL);
|
2014-07-28 21:23:00 +08:00
|
|
|
RESET_DOC_COMMENT(); }
|
|
|
|
| T_NAMESPACE namespace_name { RESET_DOC_COMMENT(); }
|
2014-07-22 19:52:35 +08:00
|
|
|
'{' top_statement_list '}'
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_NAMESPACE, $2, $5); }
|
2014-07-28 21:23:00 +08:00
|
|
|
| T_NAMESPACE { RESET_DOC_COMMENT(); }
|
2014-07-22 19:52:35 +08:00
|
|
|
'{' top_statement_list '}'
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_NAMESPACE, NULL, $4); }
|
2015-03-08 04:59:20 +08:00
|
|
|
| T_USE mixed_group_use_declaration ';' { $$ = $2; }
|
2015-03-16 18:43:21 +08:00
|
|
|
| T_USE use_type group_use_declaration ';' { $$ = $3; $$->attr = $2; }
|
2016-10-07 05:09:41 +08:00
|
|
|
| T_USE use_declarations ';' { $$ = $2; $$->attr = ZEND_SYMBOL_CLASS; }
|
2015-03-16 18:43:21 +08:00
|
|
|
| T_USE use_type use_declarations ';' { $$ = $3; $$->attr = $2; }
|
2015-01-29 13:16:53 +08:00
|
|
|
| T_CONST const_list ';' { $$ = $2; }
|
1999-05-15 23:47:24 +08:00
|
|
|
;
|
|
|
|
|
2015-03-08 04:59:20 +08:00
|
|
|
use_type:
|
2016-10-07 05:09:41 +08:00
|
|
|
T_FUNCTION { $$ = ZEND_SYMBOL_FUNCTION; }
|
|
|
|
| T_CONST { $$ = ZEND_SYMBOL_CONST; }
|
2015-03-08 04:59:20 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
group_use_declaration:
|
2017-04-21 02:08:11 +08:00
|
|
|
namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
2015-08-19 06:16:06 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4); }
|
2017-04-21 02:08:11 +08:00
|
|
|
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
2015-08-19 06:16:06 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_GROUP_USE, $2, $5); }
|
2015-01-29 13:16:53 +08:00
|
|
|
;
|
|
|
|
|
2015-03-08 04:59:20 +08:00
|
|
|
mixed_group_use_declaration:
|
2017-04-21 02:08:11 +08:00
|
|
|
namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
2015-08-19 06:16:06 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_GROUP_USE, $1, $4);}
|
2017-04-21 02:08:11 +08:00
|
|
|
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
2015-08-19 06:16:06 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_GROUP_USE, $2, $5); }
|
2015-01-19 13:22:23 +08:00
|
|
|
;
|
|
|
|
|
2017-04-21 02:08:11 +08:00
|
|
|
possible_comma:
|
|
|
|
/* empty */
|
|
|
|
| ','
|
|
|
|
;
|
|
|
|
|
2015-01-19 13:22:23 +08:00
|
|
|
inline_use_declarations:
|
|
|
|
inline_use_declarations ',' inline_use_declaration
|
|
|
|
{ $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| inline_use_declaration
|
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_USE, $1); }
|
|
|
|
;
|
|
|
|
|
2015-08-20 17:47:43 +08:00
|
|
|
unprefixed_use_declarations:
|
|
|
|
unprefixed_use_declarations ',' unprefixed_use_declaration
|
|
|
|
{ $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| unprefixed_use_declaration
|
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_USE, $1); }
|
2015-01-19 13:22:23 +08:00
|
|
|
;
|
|
|
|
|
2008-06-08 17:38:47 +08:00
|
|
|
use_declarations:
|
|
|
|
use_declarations ',' use_declaration
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $3); }
|
2008-06-08 17:38:47 +08:00
|
|
|
| use_declaration
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_USE, $1); }
|
2008-08-12 18:23:02 +08:00
|
|
|
;
|
2008-06-08 17:38:47 +08:00
|
|
|
|
2015-08-20 17:47:43 +08:00
|
|
|
inline_use_declaration:
|
2016-10-07 05:09:41 +08:00
|
|
|
unprefixed_use_declaration { $$ = $1; $$->attr = ZEND_SYMBOL_CLASS; }
|
2015-08-20 17:47:43 +08:00
|
|
|
| use_type unprefixed_use_declaration { $$ = $2; $$->attr = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
unprefixed_use_declaration:
|
2014-07-22 04:49:31 +08:00
|
|
|
namespace_name
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, NULL); }
|
2014-07-22 04:49:31 +08:00
|
|
|
| namespace_name T_AS T_STRING
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_USE_ELEM, $1, $3); }
|
2015-08-20 17:47:43 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
use_declaration:
|
|
|
|
unprefixed_use_declaration { $$ = $1; }
|
|
|
|
| T_NS_SEPARATOR unprefixed_use_declaration { $$ = $2; }
|
2008-08-12 18:23:02 +08:00
|
|
|
;
|
2008-06-08 17:38:47 +08:00
|
|
|
|
2014-07-22 17:55:07 +08:00
|
|
|
const_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
const_list ',' const_decl { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| const_decl { $$ = zend_ast_create_list(1, ZEND_AST_CONST_DECL, $1); }
|
2007-09-29 03:52:53 +08:00
|
|
|
;
|
1999-05-15 23:47:24 +08:00
|
|
|
|
|
|
|
inner_statement_list:
|
2014-07-11 05:04:42 +08:00
|
|
|
inner_statement_list inner_statement
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $2); }
|
1999-05-15 23:47:24 +08:00
|
|
|
| /* empty */
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(0, ZEND_AST_STMT_LIST); }
|
1999-05-15 23:47:24 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
inner_statement:
|
2014-08-22 06:40:07 +08:00
|
|
|
statement { $$ = $1; }
|
2014-12-02 02:44:07 +08:00
|
|
|
| function_declaration_statement { $$ = $1; }
|
|
|
|
| class_declaration_statement { $$ = $1; }
|
|
|
|
| trait_declaration_statement { $$ = $1; }
|
|
|
|
| interface_declaration_statement { $$ = $1; }
|
2014-07-11 05:04:42 +08:00
|
|
|
| T_HALT_COMPILER '(' ')' ';'
|
2017-09-24 21:24:51 +08:00
|
|
|
{ $$ = NULL; zend_throw_exception(zend_ce_compile_error,
|
|
|
|
"__HALT_COMPILER() can only be used from the outermost scope", 0); YYERROR; }
|
1999-05-15 23:47:24 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
statement:
|
2014-08-30 02:52:26 +08:00
|
|
|
'{' inner_statement_list '}' { $$ = $2; }
|
|
|
|
| if_stmt { $$ = $1; }
|
|
|
|
| alt_if_stmt { $$ = $1; }
|
2014-08-30 00:46:46 +08:00
|
|
|
| T_WHILE '(' expr ')' while_statement
|
|
|
|
{ $$ = zend_ast_create(ZEND_AST_WHILE, $3, $5); }
|
|
|
|
| T_DO statement T_WHILE '(' expr ')' ';'
|
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DO_WHILE, $2, $5); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_FOR '(' for_exprs ';' for_exprs ';' for_exprs ')' for_statement
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_FOR, $3, $5, $7, $9); }
|
2014-08-30 00:46:46 +08:00
|
|
|
| T_SWITCH '(' expr ')' switch_case_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_SWITCH, $3, $5); }
|
2014-08-30 00:51:58 +08:00
|
|
|
| T_BREAK optional_expr ';' { $$ = zend_ast_create(ZEND_AST_BREAK, $2); }
|
|
|
|
| T_CONTINUE optional_expr ';' { $$ = zend_ast_create(ZEND_AST_CONTINUE, $2); }
|
|
|
|
| T_RETURN optional_expr ';' { $$ = zend_ast_create(ZEND_AST_RETURN, $2); }
|
2014-08-30 02:52:26 +08:00
|
|
|
| T_GLOBAL global_var_list ';' { $$ = $2; }
|
|
|
|
| T_STATIC static_var_list ';' { $$ = $2; }
|
|
|
|
| T_ECHO echo_expr_list ';' { $$ = $2; }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_INLINE_HTML { $$ = zend_ast_create(ZEND_AST_ECHO, $1); }
|
|
|
|
| expr ';' { $$ = $1; }
|
2017-10-08 01:57:07 +08:00
|
|
|
| T_UNSET '(' unset_variables possible_comma ')' ';' { $$ = $3; }
|
2014-07-11 18:16:21 +08:00
|
|
|
| T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_FOREACH, $3, $5, NULL, $7); }
|
2014-07-11 18:16:21 +08:00
|
|
|
| T_FOREACH '(' expr T_AS foreach_variable T_DOUBLE_ARROW foreach_variable ')'
|
|
|
|
foreach_statement
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_FOREACH, $3, $7, $5, $9); }
|
2014-08-18 22:07:18 +08:00
|
|
|
| T_DECLARE '(' const_list ')'
|
2017-09-24 21:24:51 +08:00
|
|
|
{ if (!zend_handle_encoding_declaration($3)) { YYERROR; } }
|
2014-08-22 06:40:07 +08:00
|
|
|
declare_statement
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DECLARE, $3, $6); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| ';' /* empty statement */ { $$ = NULL; }
|
2014-07-12 19:50:58 +08:00
|
|
|
| T_TRY '{' inner_statement_list '}' catch_list finally_statement
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_TRY, $3, $5, $6); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_THROW expr ';' { $$ = zend_ast_create(ZEND_AST_THROW, $2); }
|
|
|
|
| T_GOTO T_STRING ';' { $$ = zend_ast_create(ZEND_AST_GOTO, $2); }
|
|
|
|
| T_STRING ':' { $$ = zend_ast_create(ZEND_AST_LABEL, $1); }
|
2002-03-03 04:38:52 +08:00
|
|
|
;
|
|
|
|
|
2014-07-12 19:50:58 +08:00
|
|
|
catch_list:
|
|
|
|
/* empty */
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(0, ZEND_AST_CATCH_LIST); }
|
2016-05-02 06:47:08 +08:00
|
|
|
| catch_list T_CATCH '(' catch_name_list T_VARIABLE ')' '{' inner_statement_list '}'
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_CATCH, $4, $5, $8)); }
|
2002-03-01 22:04:51 +08:00
|
|
|
;
|
|
|
|
|
2016-05-02 06:47:08 +08:00
|
|
|
catch_name_list:
|
|
|
|
name { $$ = zend_ast_create_list(1, ZEND_AST_NAME_LIST, $1); }
|
|
|
|
| catch_name_list '|' name { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
;
|
|
|
|
|
2014-07-12 19:50:58 +08:00
|
|
|
finally_statement:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = NULL; }
|
2014-08-30 02:52:26 +08:00
|
|
|
| T_FINALLY '{' inner_statement_list '}' { $$ = $3; }
|
2002-02-14 03:26:07 +08:00
|
|
|
;
|
|
|
|
|
2000-06-16 02:48:33 +08:00
|
|
|
unset_variables:
|
2014-08-22 06:40:07 +08:00
|
|
|
unset_variable { $$ = zend_ast_create_list(1, ZEND_AST_STMT_LIST, $1); }
|
|
|
|
| unset_variables ',' unset_variable { $$ = zend_ast_list_add($1, $3); }
|
2000-06-16 02:48:33 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
unset_variable:
|
2014-08-22 06:40:07 +08:00
|
|
|
variable { $$ = zend_ast_create(ZEND_AST_UNSET, $1); }
|
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:
|
2016-03-12 00:28:45 +08:00
|
|
|
function returns_ref T_STRING backup_doc_comment '(' parameter_list ')' return_type
|
2016-05-13 06:40:15 +08:00
|
|
|
backup_fn_flags '{' inner_statement_list '}' backup_fn_flags
|
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_FUNC_DECL, $2 | $13, $1, $4,
|
|
|
|
zend_ast_get_str($3), $6, NULL, $11, $8); CG(extra_fn_flags) = $9; }
|
2002-09-24 01:20:59 +08:00
|
|
|
;
|
|
|
|
|
2002-12-07 01:09:44 +08:00
|
|
|
is_reference:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = 0; }
|
|
|
|
| '&' { $$ = ZEND_PARAM_REF; }
|
2002-12-07 01:09:44 +08:00
|
|
|
;
|
|
|
|
|
2013-09-27 00:39:17 +08:00
|
|
|
is_variadic:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = 0; }
|
|
|
|
| T_ELLIPSIS { $$ = ZEND_PARAM_VARIADIC; }
|
2013-09-27 00:39:17 +08:00
|
|
|
;
|
2002-12-07 01:09:44 +08:00
|
|
|
|
2014-07-21 23:34:00 +08:00
|
|
|
class_declaration_statement:
|
2014-12-02 02:44:07 +08:00
|
|
|
class_modifiers T_CLASS { $<num>$ = CG(zend_lineno); }
|
2014-08-27 04:30:18 +08:00
|
|
|
T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}'
|
2015-01-09 04:40:36 +08:00
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, $1, $<num>3, $7, zend_ast_get_str($4), $5, $6, $9, NULL); }
|
2014-12-02 02:44:07 +08:00
|
|
|
| T_CLASS { $<num>$ = CG(zend_lineno); }
|
|
|
|
T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}'
|
2015-01-09 04:40:36 +08:00
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, 0, $<num>2, $6, zend_ast_get_str($3), $4, $5, $8, NULL); }
|
2014-12-02 02:44:07 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
class_modifiers:
|
|
|
|
class_modifier { $$ = $1; }
|
2017-09-24 21:24:51 +08:00
|
|
|
| class_modifiers class_modifier
|
|
|
|
{ $$ = zend_add_class_modifier($1, $2); if (!$$) { YYERROR; } }
|
2014-12-02 02:44:07 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
class_modifier:
|
|
|
|
T_ABSTRACT { $$ = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; }
|
|
|
|
| T_FINAL { $$ = ZEND_ACC_FINAL; }
|
2002-07-18 02:36:29 +08:00
|
|
|
;
|
|
|
|
|
2014-12-02 02:44:07 +08:00
|
|
|
trait_declaration_statement:
|
|
|
|
T_TRAIT { $<num>$ = CG(zend_lineno); }
|
2014-12-06 01:09:49 +08:00
|
|
|
T_STRING backup_doc_comment '{' class_statement_list '}'
|
2015-01-09 04:40:36 +08:00
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, ZEND_ACC_TRAIT, $<num>2, $4, zend_ast_get_str($3), NULL, NULL, $6, NULL); }
|
2014-12-02 02:44:07 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
interface_declaration_statement:
|
|
|
|
T_INTERFACE { $<num>$ = CG(zend_lineno); }
|
|
|
|
T_STRING interface_extends_list backup_doc_comment '{' class_statement_list '}'
|
2015-01-09 04:40:36 +08:00
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, ZEND_ACC_INTERFACE, $<num>2, $5, zend_ast_get_str($3), NULL, $4, $7, NULL); }
|
2014-07-21 23:14:01 +08:00
|
|
|
;
|
|
|
|
|
2002-07-18 02:36:29 +08:00
|
|
|
extends_from:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| T_EXTENDS name { $$ = $2; }
|
2003-03-05 19:14:44 +08:00
|
|
|
;
|
|
|
|
|
2014-07-21 23:14:01 +08:00
|
|
|
interface_extends_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| T_EXTENDS name_list { $$ = $2; }
|
2004-02-12 06:13:39 +08:00
|
|
|
;
|
|
|
|
|
2003-03-05 19:14:44 +08:00
|
|
|
implements_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| T_IMPLEMENTS name_list { $$ = $2; }
|
2001-12-22 23:31:44 +08:00
|
|
|
;
|
1999-05-15 23:47:24 +08:00
|
|
|
|
2003-07-24 20:38:33 +08:00
|
|
|
foreach_variable:
|
2014-08-22 06:40:07 +08:00
|
|
|
variable { $$ = $1; }
|
|
|
|
| '&' variable { $$ = zend_ast_create(ZEND_AST_REF, $2); }
|
2016-07-07 03:15:05 +08:00
|
|
|
| T_LIST '(' array_pair_list ')' { $$ = $3; $$->attr = ZEND_ARRAY_SYNTAX_LIST; }
|
|
|
|
| '[' array_pair_list ']' { $$ = $2; $$->attr = ZEND_ARRAY_SYNTAX_SHORT; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
for_statement:
|
2014-08-22 06:40:07 +08:00
|
|
|
statement { $$ = $1; }
|
2014-08-30 02:52:26 +08:00
|
|
|
| ':' inner_statement_list T_ENDFOR ';' { $$ = $2; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
foreach_statement:
|
2014-08-22 06:40:07 +08:00
|
|
|
statement { $$ = $1; }
|
2014-08-30 02:52:26 +08:00
|
|
|
| ':' inner_statement_list T_ENDFOREACH ';' { $$ = $2; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2000-01-25 03:00:30 +08:00
|
|
|
declare_statement:
|
2014-08-22 06:40:07 +08:00
|
|
|
statement { $$ = $1; }
|
2014-08-30 02:52:26 +08:00
|
|
|
| ':' inner_statement_list T_ENDDECLARE ';' { $$ = $2; }
|
2000-01-25 03:00:30 +08:00
|
|
|
;
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
switch_case_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
'{' case_list '}' { $$ = $2; }
|
|
|
|
| '{' ';' case_list '}' { $$ = $3; }
|
|
|
|
| ':' case_list T_ENDSWITCH ';' { $$ = $2; }
|
|
|
|
| ':' ';' case_list T_ENDSWITCH ';' { $$ = $3; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
case_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = zend_ast_create_list(0, ZEND_AST_SWITCH_LIST); }
|
2014-07-11 21:31:47 +08:00
|
|
|
| case_list T_CASE expr case_separator inner_statement_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_SWITCH_CASE, $3, $5)); }
|
2014-07-11 21:31:47 +08:00
|
|
|
| case_list T_DEFAULT case_separator inner_statement_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_SWITCH_CASE, NULL, $4)); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
case_separator:
|
|
|
|
':'
|
|
|
|
| ';'
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
while_statement:
|
2014-08-22 06:40:07 +08:00
|
|
|
statement { $$ = $1; }
|
2014-08-30 02:52:26 +08:00
|
|
|
| ':' inner_statement_list T_ENDWHILE ';' { $$ = $2; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2014-07-10 22:38:04 +08:00
|
|
|
if_stmt_without_else:
|
2014-08-30 00:46:46 +08:00
|
|
|
T_IF '(' expr ')' statement
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_IF,
|
2014-08-30 00:46:46 +08:00
|
|
|
zend_ast_create(ZEND_AST_IF_ELEM, $3, $5)); }
|
|
|
|
| if_stmt_without_else T_ELSEIF '(' expr ')' statement
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1,
|
2014-08-30 00:46:46 +08:00
|
|
|
zend_ast_create(ZEND_AST_IF_ELEM, $4, $6)); }
|
2014-07-10 22:38:04 +08:00
|
|
|
;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-07-10 22:38:04 +08:00
|
|
|
if_stmt:
|
2015-05-26 18:11:07 +08:00
|
|
|
if_stmt_without_else %prec T_NOELSE { $$ = $1; }
|
2014-07-10 22:38:04 +08:00
|
|
|
| if_stmt_without_else T_ELSE statement
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, zend_ast_create(ZEND_AST_IF_ELEM, NULL, $3)); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2014-07-11 05:04:42 +08:00
|
|
|
alt_if_stmt_without_else:
|
2014-08-30 00:46:46 +08:00
|
|
|
T_IF '(' expr ')' ':' inner_statement_list
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_IF,
|
2014-08-30 02:52:26 +08:00
|
|
|
zend_ast_create(ZEND_AST_IF_ELEM, $3, $6)); }
|
2014-08-30 00:46:46 +08:00
|
|
|
| alt_if_stmt_without_else T_ELSEIF '(' expr ')' ':' inner_statement_list
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1,
|
2014-08-30 02:52:26 +08:00
|
|
|
zend_ast_create(ZEND_AST_IF_ELEM, $4, $7)); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2014-07-11 05:04:42 +08:00
|
|
|
alt_if_stmt:
|
2014-08-22 06:40:07 +08:00
|
|
|
alt_if_stmt_without_else T_ENDIF ';' { $$ = $1; }
|
2014-07-11 05:04:42 +08:00
|
|
|
| alt_if_stmt_without_else T_ELSE ':' inner_statement_list T_ENDIF ';'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1,
|
2014-08-30 02:52:26 +08:00
|
|
|
zend_ast_create(ZEND_AST_IF_ELEM, NULL, $4)); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2006-05-12 05:07:39 +08:00
|
|
|
parameter_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
non_empty_parameter_list { $$ = $1; }
|
|
|
|
| /* empty */ { $$ = zend_ast_create_list(0, ZEND_AST_PARAM_LIST); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
non_empty_parameter_list:
|
2013-09-27 01:43:32 +08:00
|
|
|
parameter
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_PARAM_LIST, $1); }
|
2013-09-27 01:43:32 +08:00
|
|
|
| non_empty_parameter_list ',' parameter
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $3); }
|
2013-09-27 01:43:32 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
parameter:
|
2014-07-15 05:03:53 +08:00
|
|
|
optional_type is_reference is_variadic T_VARIABLE
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_PARAM, $2 | $3, $1, $4, NULL); }
|
2014-07-15 05:03:53 +08:00
|
|
|
| optional_type is_reference is_variadic T_VARIABLE '=' expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_PARAM, $2 | $3, $1, $4, $6); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2014-07-15 05:03:53 +08:00
|
|
|
optional_type:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = NULL; }
|
2016-04-29 05:26:57 +08:00
|
|
|
| type_expr { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
|
|
|
type_expr:
|
|
|
|
type { $$ = $1; }
|
|
|
|
| '?' type { $$ = $2; $$->attr |= ZEND_TYPE_NULLABLE; }
|
2015-01-09 04:40:36 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
type:
|
|
|
|
T_ARRAY { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_ARRAY); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_CALLABLE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_CALLABLE); }
|
|
|
|
| name { $$ = $1; }
|
2003-03-06 22:31:17 +08:00
|
|
|
;
|
|
|
|
|
2015-01-09 04:40:36 +08:00
|
|
|
return_type:
|
|
|
|
/* empty */ { $$ = NULL; }
|
2016-04-29 05:26:57 +08:00
|
|
|
| ':' type_expr { $$ = $2; }
|
2015-01-09 04:40:36 +08:00
|
|
|
;
|
|
|
|
|
2014-07-13 19:11:55 +08:00
|
|
|
argument_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
'(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); }
|
2017-10-08 01:57:07 +08:00
|
|
|
| '(' non_empty_argument_list possible_comma ')' { $$ = $2; }
|
2014-06-07 19:06:53 +08:00
|
|
|
;
|
|
|
|
|
2014-07-13 19:11:55 +08:00
|
|
|
non_empty_argument_list:
|
|
|
|
argument
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1); }
|
2014-07-13 19:11:55 +08:00
|
|
|
| non_empty_argument_list ',' argument
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
;
|
|
|
|
|
2014-07-13 19:11:55 +08:00
|
|
|
argument:
|
2014-08-30 00:42:05 +08:00
|
|
|
expr { $$ = $1; }
|
|
|
|
| T_ELLIPSIS expr { $$ = zend_ast_create(ZEND_AST_UNPACK, $2); }
|
2014-06-07 19:06:53 +08:00
|
|
|
;
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
global_var_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
global_var_list ',' global_var { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| global_var { $$ = zend_ast_create_list(1, ZEND_AST_STMT_LIST, $1); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
global_var:
|
2014-06-07 19:06:53 +08:00
|
|
|
simple_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_GLOBAL, zend_ast_create(ZEND_AST_VAR, $1)); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
static_var_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
static_var_list ',' static_var { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| static_var { $$ = zend_ast_create_list(1, ZEND_AST_STMT_LIST, $1); }
|
2014-07-12 23:00:53 +08:00
|
|
|
;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-07-12 23:00:53 +08:00
|
|
|
static_var:
|
2014-08-22 06:40:07 +08:00
|
|
|
T_VARIABLE { $$ = zend_ast_create(ZEND_AST_STATIC, $1, NULL); }
|
|
|
|
| T_VARIABLE '=' expr { $$ = zend_ast_create(ZEND_AST_STATIC, $1, $3); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
class_statement_list:
|
|
|
|
class_statement_list class_statement
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $2); }
|
1999-04-08 02:10:10 +08:00
|
|
|
| /* empty */
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(0, ZEND_AST_STMT_LIST); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
class_statement:
|
2014-07-19 20:54:56 +08:00
|
|
|
variable_modifiers property_list ';'
|
2015-10-07 04:32:23 +08:00
|
|
|
{ $$ = $2; $$->attr = $1; }
|
2015-12-08 17:40:42 +08:00
|
|
|
| method_modifiers T_CONST class_const_list ';'
|
|
|
|
{ $$ = $3; $$->attr = $1; }
|
2014-07-20 04:39:01 +08:00
|
|
|
| T_USE name_list trait_adaptations
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_USE_TRAIT, $2, $3); }
|
2016-03-12 00:28:45 +08:00
|
|
|
| method_modifiers function returns_ref identifier backup_doc_comment '(' parameter_list ')'
|
2016-05-13 06:40:15 +08:00
|
|
|
return_type backup_fn_flags method_body backup_fn_flags
|
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_METHOD, $3 | $1 | $12, $2, $5,
|
|
|
|
zend_ast_get_str($4), $7, NULL, $11, $9); CG(extra_fn_flags) = $10; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2014-07-20 04:39:01 +08:00
|
|
|
name_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
name { $$ = zend_ast_create_list(1, ZEND_AST_NAME_LIST, $1); }
|
|
|
|
| name_list ',' name { $$ = zend_ast_list_add($1, $3); }
|
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:
|
2014-08-22 06:40:07 +08:00
|
|
|
';' { $$ = NULL; }
|
|
|
|
| '{' '}' { $$ = NULL; }
|
|
|
|
| '{' trait_adaptation_list '}' { $$ = $2; }
|
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_adaptation_list:
|
2014-07-20 04:39:01 +08:00
|
|
|
trait_adaptation
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_TRAIT_ADAPTATIONS, $1); }
|
2014-07-20 04:39:01 +08:00
|
|
|
| trait_adaptation_list trait_adaptation
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $2); }
|
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
|
|
|
;
|
|
|
|
|
2014-07-20 04:39:01 +08:00
|
|
|
trait_adaptation:
|
2014-08-22 06:40:07 +08:00
|
|
|
trait_precedence ';' { $$ = $1; }
|
|
|
|
| trait_alias ';' { $$ = $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_precedence:
|
2014-07-20 04:39:01 +08:00
|
|
|
absolute_trait_method_reference T_INSTEADOF name_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_TRAIT_PRECEDENCE, $1, $3); }
|
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
|
|
|
;
|
|
|
|
|
2014-07-20 04:39:01 +08:00
|
|
|
trait_alias:
|
2015-05-26 02:26:57 +08:00
|
|
|
trait_method_reference T_AS T_STRING
|
2018-03-15 17:46:19 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_TRAIT_ALIAS, $1, $3); }
|
2015-05-26 02:26:57 +08:00
|
|
|
| trait_method_reference T_AS reserved_non_modifiers
|
2018-03-15 17:46:19 +08:00
|
|
|
{ zval zv; zend_lex_tstring(&zv); $$ = zend_ast_create(ZEND_AST_TRAIT_ALIAS, $1, zend_ast_create_zval(&zv)); }
|
2015-05-26 02:26:57 +08:00
|
|
|
| trait_method_reference T_AS member_modifier identifier
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_TRAIT_ALIAS, $3, $1, $4); }
|
2015-06-20 19:10:51 +08:00
|
|
|
| trait_method_reference T_AS member_modifier
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_TRAIT_ALIAS, $3, $1, NULL); }
|
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:
|
2015-03-09 13:24:50 +08:00
|
|
|
identifier
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_METHOD_REFERENCE, NULL, $1); }
|
|
|
|
| absolute_trait_method_reference { $$ = $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
|
|
|
;
|
|
|
|
|
2014-07-20 04:39:01 +08:00
|
|
|
absolute_trait_method_reference:
|
2015-03-09 13:24:50 +08:00
|
|
|
name T_PAAMAYIM_NEKUDOTAYIM identifier
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_METHOD_REFERENCE, $1, $3); }
|
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
|
|
|
;
|
|
|
|
|
2003-02-11 17:48:37 +08:00
|
|
|
method_body:
|
2014-08-22 06:40:07 +08:00
|
|
|
';' /* abstract method */ { $$ = NULL; }
|
|
|
|
| '{' inner_statement_list '}' { $$ = $2; }
|
2003-02-11 17:48:37 +08:00
|
|
|
;
|
|
|
|
|
2002-12-09 20:10:17 +08:00
|
|
|
variable_modifiers:
|
2014-08-22 06:40:07 +08:00
|
|
|
non_empty_member_modifiers { $$ = $1; }
|
|
|
|
| T_VAR { $$ = ZEND_ACC_PUBLIC; }
|
2002-11-06 03:37:31 +08:00
|
|
|
;
|
2002-12-07 01:09:44 +08:00
|
|
|
|
|
|
|
method_modifiers:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = ZEND_ACC_PUBLIC; }
|
2014-07-27 18:17:36 +08:00
|
|
|
| non_empty_member_modifiers
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = $1; if (!($$ & ZEND_ACC_PPP_MASK)) { $$ |= 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:
|
2014-08-22 06:40:07 +08:00
|
|
|
member_modifier { $$ = $1; }
|
2014-07-27 18:17:36 +08:00
|
|
|
| non_empty_member_modifiers member_modifier
|
2017-09-24 21:24:51 +08:00
|
|
|
{ $$ = zend_add_member_modifier($1, $2); if (!$$) { YYERROR; } }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2003-02-11 17:48:37 +08:00
|
|
|
member_modifier:
|
2014-08-22 06:40:07 +08:00
|
|
|
T_PUBLIC { $$ = ZEND_ACC_PUBLIC; }
|
|
|
|
| T_PROTECTED { $$ = ZEND_ACC_PROTECTED; }
|
|
|
|
| T_PRIVATE { $$ = ZEND_ACC_PRIVATE; }
|
|
|
|
| T_STATIC { $$ = ZEND_ACC_STATIC; }
|
|
|
|
| T_ABSTRACT { $$ = ZEND_ACC_ABSTRACT; }
|
|
|
|
| T_FINAL { $$ = ZEND_ACC_FINAL; }
|
2002-12-07 01:09:44 +08:00
|
|
|
;
|
|
|
|
|
2014-07-19 20:54:56 +08:00
|
|
|
property_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
property_list ',' property { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| property { $$ = zend_ast_create_list(1, ZEND_AST_PROP_DECL, $1); }
|
2014-07-19 20:54:56 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
property:
|
2015-10-07 04:32:23 +08:00
|
|
|
T_VARIABLE backup_doc_comment
|
|
|
|
{ $$ = zend_ast_create(ZEND_AST_PROP_ELEM, $1, NULL, ($2 ? zend_ast_create_zval_from_str($2) : NULL)); }
|
|
|
|
| T_VARIABLE '=' expr backup_doc_comment
|
|
|
|
{ $$ = zend_ast_create(ZEND_AST_PROP_ELEM, $1, $3, ($4 ? zend_ast_create_zval_from_str($4) : NULL)); }
|
2001-11-27 02:05:01 +08:00
|
|
|
;
|
1999-08-19 23:15:34 +08:00
|
|
|
|
2014-07-19 21:13:50 +08:00
|
|
|
class_const_list:
|
2015-03-09 13:24:50 +08:00
|
|
|
class_const_list ',' class_const_decl { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| class_const_decl { $$ = zend_ast_create_list(1, ZEND_AST_CLASS_CONST_DECL, $1); }
|
|
|
|
;
|
|
|
|
|
|
|
|
class_const_decl:
|
2015-12-08 17:40:42 +08:00
|
|
|
identifier '=' expr backup_doc_comment { $$ = zend_ast_create(ZEND_AST_CONST_ELEM, $1, $3, ($4 ? zend_ast_create_zval_from_str($4) : NULL)); }
|
2014-07-19 21:13:50 +08:00
|
|
|
;
|
|
|
|
|
2014-07-22 17:55:07 +08:00
|
|
|
const_decl:
|
2015-12-08 17:40:42 +08:00
|
|
|
T_STRING '=' expr backup_doc_comment { $$ = zend_ast_create(ZEND_AST_CONST_ELEM, $1, $3, ($4 ? zend_ast_create_zval_from_str($4) : NULL)); }
|
2001-12-01 00:29:47 +08:00
|
|
|
;
|
|
|
|
|
2006-05-12 05:07:39 +08:00
|
|
|
echo_expr_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
echo_expr_list ',' echo_expr { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| echo_expr { $$ = zend_ast_create_list(1, ZEND_AST_STMT_LIST, $1); }
|
2014-07-08 03:14:14 +08:00
|
|
|
;
|
|
|
|
echo_expr:
|
2014-08-22 06:40:07 +08:00
|
|
|
expr { $$ = zend_ast_create(ZEND_AST_ECHO, $1); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2014-08-22 06:40:07 +08:00
|
|
|
for_exprs:
|
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| non_empty_for_exprs { $$ = $1; }
|
1999-08-19 23:15:34 +08:00
|
|
|
;
|
|
|
|
|
2014-08-22 06:40:07 +08:00
|
|
|
non_empty_for_exprs:
|
|
|
|
non_empty_for_exprs ',' expr { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| expr { $$ = zend_ast_create_list(1, ZEND_AST_EXPR_LIST, $1); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2015-04-26 21:02:57 +08:00
|
|
|
anonymous_class:
|
2015-04-26 21:54:30 +08:00
|
|
|
T_CLASS { $<num>$ = CG(zend_lineno); } ctor_arguments
|
|
|
|
extends_from implements_list backup_doc_comment '{' class_statement_list '}' {
|
|
|
|
zend_ast *decl = zend_ast_create_decl(
|
|
|
|
ZEND_AST_CLASS, ZEND_ACC_ANON_CLASS, $<num>2, $6, NULL,
|
|
|
|
$4, $5, $8, NULL);
|
|
|
|
$$ = zend_ast_create(ZEND_AST_NEW, decl, $3);
|
|
|
|
}
|
2015-04-26 21:02:57 +08:00
|
|
|
;
|
|
|
|
|
2011-11-06 21:25:45 +08:00
|
|
|
new_expr:
|
2014-06-15 00:30:18 +08:00
|
|
|
T_NEW class_name_reference ctor_arguments
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_NEW, $2, $3); }
|
2015-04-26 21:54:30 +08:00
|
|
|
| T_NEW anonymous_class
|
|
|
|
{ $$ = $2; }
|
2011-11-06 21:25:45 +08:00
|
|
|
;
|
|
|
|
|
2018-06-24 19:34:32 +08:00
|
|
|
expr:
|
|
|
|
variable
|
|
|
|
{ $$ = $1; }
|
|
|
|
| T_LIST '(' array_pair_list ')' '=' expr
|
2016-07-07 03:15:05 +08:00
|
|
|
{ $3->attr = ZEND_ARRAY_SYNTAX_LIST; $$ = zend_ast_create(ZEND_AST_ASSIGN, $3, $6); }
|
2016-04-05 06:34:42 +08:00
|
|
|
| '[' array_pair_list ']' '=' expr
|
2016-07-07 03:15:05 +08:00
|
|
|
{ $2->attr = ZEND_ARRAY_SYNTAX_SHORT; $$ = zend_ast_create(ZEND_AST_ASSIGN, $2, $5); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable '=' expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_ASSIGN, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable '=' '&' variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_ASSIGN_REF, $1, $4); }
|
|
|
|
| T_CLONE expr { $$ = zend_ast_create(ZEND_AST_CLONE, $2); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_PLUS_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_ADD, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_MINUS_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_SUB, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_MUL_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_MUL, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_POW_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_POW, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_DIV_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_DIV, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_CONCAT_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_CONCAT, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_MOD_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_MOD, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_AND_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_BW_AND, $1, $3); }
|
2015-01-03 17:22:58 +08:00
|
|
|
| variable T_OR_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_BW_OR, $1, $3); }
|
2015-01-03 17:22:58 +08:00
|
|
|
| variable T_XOR_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_BW_XOR, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_SL_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_SL, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable T_SR_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_assign_op(ZEND_ASSIGN_SR, $1, $3); }
|
|
|
|
| variable T_INC { $$ = zend_ast_create(ZEND_AST_POST_INC, $1); }
|
|
|
|
| T_INC variable { $$ = zend_ast_create(ZEND_AST_PRE_INC, $2); }
|
|
|
|
| variable T_DEC { $$ = zend_ast_create(ZEND_AST_POST_DEC, $1); }
|
|
|
|
| T_DEC variable { $$ = zend_ast_create(ZEND_AST_PRE_DEC, $2); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_BOOLEAN_OR expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_OR, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_BOOLEAN_AND expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_AND, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_LOGICAL_OR expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_OR, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_LOGICAL_AND expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_AND, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_LOGICAL_XOR expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_BOOL_XOR, $1, $3); }
|
|
|
|
| expr '|' expr { $$ = zend_ast_create_binary_op(ZEND_BW_OR, $1, $3); }
|
|
|
|
| expr '&' expr { $$ = zend_ast_create_binary_op(ZEND_BW_AND, $1, $3); }
|
|
|
|
| expr '^' expr { $$ = zend_ast_create_binary_op(ZEND_BW_XOR, $1, $3); }
|
|
|
|
| expr '.' expr { $$ = zend_ast_create_binary_op(ZEND_CONCAT, $1, $3); }
|
|
|
|
| expr '+' expr { $$ = zend_ast_create_binary_op(ZEND_ADD, $1, $3); }
|
|
|
|
| expr '-' expr { $$ = zend_ast_create_binary_op(ZEND_SUB, $1, $3); }
|
|
|
|
| expr '*' expr { $$ = zend_ast_create_binary_op(ZEND_MUL, $1, $3); }
|
|
|
|
| expr T_POW expr { $$ = zend_ast_create_binary_op(ZEND_POW, $1, $3); }
|
|
|
|
| expr '/' expr { $$ = zend_ast_create_binary_op(ZEND_DIV, $1, $3); }
|
|
|
|
| expr '%' expr { $$ = zend_ast_create_binary_op(ZEND_MOD, $1, $3); }
|
|
|
|
| expr T_SL expr { $$ = zend_ast_create_binary_op(ZEND_SL, $1, $3); }
|
|
|
|
| expr T_SR expr { $$ = zend_ast_create_binary_op(ZEND_SR, $1, $3); }
|
|
|
|
| '+' expr %prec T_INC { $$ = zend_ast_create(ZEND_AST_UNARY_PLUS, $2); }
|
|
|
|
| '-' expr %prec T_INC { $$ = zend_ast_create(ZEND_AST_UNARY_MINUS, $2); }
|
|
|
|
| '!' expr { $$ = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BOOL_NOT, $2); }
|
|
|
|
| '~' expr { $$ = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BW_NOT, $2); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_IS_IDENTICAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_IS_IDENTICAL, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_IS_NOT_IDENTICAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_IS_NOT_IDENTICAL, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_IS_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_IS_EQUAL, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_IS_NOT_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_IS_NOT_EQUAL, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr '<' expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_IS_SMALLER, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_IS_SMALLER_OR_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_IS_SMALLER_OR_EQUAL, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr '>' expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_GREATER, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_IS_GREATER_OR_EQUAL expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_GREATER_EQUAL, $1, $3); }
|
2015-01-19 15:12:39 +08:00
|
|
|
| expr T_SPACESHIP expr
|
|
|
|
{ $$ = zend_ast_create_binary_op(ZEND_SPACESHIP, $1, $3); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr T_INSTANCEOF class_name_reference
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_INSTANCEOF, $1, $3); }
|
2014-08-30 00:46:46 +08:00
|
|
|
| '(' expr ')' { $$ = $2; }
|
2014-08-22 06:40:07 +08:00
|
|
|
| new_expr { $$ = $1; }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr '?' expr ':' expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_CONDITIONAL, $1, $3, $5); }
|
2014-06-15 00:30:18 +08:00
|
|
|
| expr '?' ':' expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_CONDITIONAL, $1, NULL, $4); }
|
2014-09-17 02:14:46 +08:00
|
|
|
| expr T_COALESCE expr
|
|
|
|
{ $$ = zend_ast_create(ZEND_AST_COALESCE, $1, $3); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| internal_functions_in_yacc { $$ = $1; }
|
2014-08-30 02:52:26 +08:00
|
|
|
| T_INT_CAST expr { $$ = zend_ast_create_cast(IS_LONG, $2); }
|
|
|
|
| T_DOUBLE_CAST expr { $$ = zend_ast_create_cast(IS_DOUBLE, $2); }
|
|
|
|
| T_STRING_CAST expr { $$ = zend_ast_create_cast(IS_STRING, $2); }
|
|
|
|
| T_ARRAY_CAST expr { $$ = zend_ast_create_cast(IS_ARRAY, $2); }
|
|
|
|
| T_OBJECT_CAST expr { $$ = zend_ast_create_cast(IS_OBJECT, $2); }
|
|
|
|
| T_BOOL_CAST expr { $$ = zend_ast_create_cast(_IS_BOOL, $2); }
|
|
|
|
| T_UNSET_CAST expr { $$ = zend_ast_create_cast(IS_NULL, $2); }
|
|
|
|
| T_EXIT exit_expr { $$ = zend_ast_create(ZEND_AST_EXIT, $2); }
|
|
|
|
| '@' expr { $$ = zend_ast_create(ZEND_AST_SILENCE, $2); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| scalar { $$ = $1; }
|
|
|
|
| '`' backticks_expr '`' { $$ = zend_ast_create(ZEND_AST_SHELL_EXEC, $2); }
|
|
|
|
| T_PRINT expr { $$ = zend_ast_create(ZEND_AST_PRINT, $2); }
|
2016-05-13 06:40:15 +08:00
|
|
|
| T_YIELD { $$ = zend_ast_create(ZEND_AST_YIELD, NULL, NULL); CG(extra_fn_flags) |= ZEND_ACC_GENERATOR; }
|
|
|
|
| T_YIELD expr { $$ = zend_ast_create(ZEND_AST_YIELD, $2, NULL); CG(extra_fn_flags) |= ZEND_ACC_GENERATOR; }
|
|
|
|
| T_YIELD expr T_DOUBLE_ARROW expr { $$ = zend_ast_create(ZEND_AST_YIELD, $4, $2); CG(extra_fn_flags) |= ZEND_ACC_GENERATOR; }
|
|
|
|
| T_YIELD_FROM expr { $$ = zend_ast_create(ZEND_AST_YIELD_FROM, $2); CG(extra_fn_flags) |= ZEND_ACC_GENERATOR; }
|
2016-03-12 00:28:45 +08:00
|
|
|
| function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type
|
2016-05-13 06:40:15 +08:00
|
|
|
backup_fn_flags '{' inner_statement_list '}' backup_fn_flags
|
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2 | $13, $1, $3,
|
2014-08-26 03:21:16 +08:00
|
|
|
zend_string_init("{closure}", sizeof("{closure}") - 1, 0),
|
2016-05-13 06:40:15 +08:00
|
|
|
$5, $7, $11, $8); CG(extra_fn_flags) = $9; }
|
2016-03-12 00:28:45 +08:00
|
|
|
| T_STATIC function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars
|
2016-05-13 06:40:15 +08:00
|
|
|
return_type backup_fn_flags '{' inner_statement_list '}' backup_fn_flags
|
|
|
|
{ $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $3 | $14 | ZEND_ACC_STATIC, $2, $4,
|
2014-08-27 04:30:18 +08:00
|
|
|
zend_string_init("{closure}", sizeof("{closure}") - 1, 0),
|
2016-05-13 06:40:15 +08:00
|
|
|
$6, $8, $12, $9); CG(extra_fn_flags) = $10; }
|
2008-07-14 17:49:03 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
function:
|
2014-08-22 06:40:07 +08:00
|
|
|
T_FUNCTION { $$ = CG(zend_lineno); }
|
2014-07-18 21:23:16 +08:00
|
|
|
;
|
|
|
|
|
2014-08-27 04:30:18 +08:00
|
|
|
backup_doc_comment:
|
|
|
|
/* empty */ { $$ = CG(doc_comment); CG(doc_comment) = NULL; }
|
|
|
|
;
|
|
|
|
|
2016-05-13 06:40:15 +08:00
|
|
|
backup_fn_flags:
|
|
|
|
/* empty */ { $$ = CG(extra_fn_flags); CG(extra_fn_flags) = 0; }
|
|
|
|
;
|
|
|
|
|
2014-07-18 21:47:46 +08:00
|
|
|
returns_ref:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = 0; }
|
|
|
|
| '&' { $$ = ZEND_ACC_RETURN_REFERENCE; }
|
2014-07-18 21:47:46 +08:00
|
|
|
;
|
|
|
|
|
2008-07-14 17:49:03 +08:00
|
|
|
lexical_vars:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| T_USE '(' lexical_var_list ')' { $$ = $3; }
|
2008-07-14 17:49:03 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
lexical_var_list:
|
2014-08-22 06:40:07 +08:00
|
|
|
lexical_var_list ',' lexical_var { $$ = zend_ast_list_add($1, $3); }
|
|
|
|
| lexical_var { $$ = zend_ast_create_list(1, ZEND_AST_CLOSURE_USES, $1); }
|
2014-07-18 18:30:39 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
lexical_var:
|
2014-08-22 06:40:07 +08:00
|
|
|
T_VARIABLE { $$ = $1; }
|
|
|
|
| '&' T_VARIABLE { $$ = $2; $$->attr = 1; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
1999-12-16 04:15:32 +08:00
|
|
|
function_call:
|
2014-07-13 19:11:55 +08:00
|
|
|
name argument_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_CALL, $1, $2); }
|
2014-07-13 19:11:55 +08:00
|
|
|
| class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_STATIC_CALL, $1, $3, $4); }
|
2014-07-13 19:11:55 +08:00
|
|
|
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_STATIC_CALL, $1, $3, $4); }
|
2014-07-13 19:11:55 +08:00
|
|
|
| callable_expr argument_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_CALL, $1, $2); }
|
1999-12-16 04:15:32 +08:00
|
|
|
;
|
|
|
|
|
2007-11-12 06:11:25 +08:00
|
|
|
class_name:
|
2014-07-20 05:30:07 +08:00
|
|
|
T_STATIC
|
2017-03-04 17:39:13 +08:00
|
|
|
{ zval zv; ZVAL_INTERNED_STR(&zv, ZSTR_KNOWN(ZEND_STR_STATIC));
|
2014-08-22 06:40:07 +08:00
|
|
|
$$ = zend_ast_create_zval_ex(&zv, ZEND_NAME_NOT_FQ); }
|
|
|
|
| name { $$ = $1; }
|
2007-11-12 06:11:25 +08:00
|
|
|
;
|
|
|
|
|
2003-06-22 18:50:43 +08:00
|
|
|
class_name_reference:
|
2014-08-22 06:40:07 +08:00
|
|
|
class_name { $$ = $1; }
|
|
|
|
| new_variable { $$ = $1; }
|
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:
|
2014-08-30 00:51:58 +08:00
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| '(' optional_expr ')' { $$ = $2; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2008-07-26 23:30:28 +08:00
|
|
|
backticks_expr:
|
2014-06-19 19:57:29 +08:00
|
|
|
/* empty */
|
2015-06-29 21:44:54 +08:00
|
|
|
{ $$ = zend_ast_create_zval_from_str(ZSTR_EMPTY_ALLOC()); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_ENCAPSED_AND_WHITESPACE { $$ = $1; }
|
2014-08-30 02:52:26 +08:00
|
|
|
| encaps_list { $$ = $1; }
|
2008-07-26 23:30:28 +08:00
|
|
|
;
|
|
|
|
|
1999-04-08 02:10:10 +08:00
|
|
|
|
|
|
|
ctor_arguments:
|
2014-08-22 06:40:07 +08:00
|
|
|
/* empty */ { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); }
|
|
|
|
| argument_list { $$ = $1; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2014-05-31 22:44:53 +08:00
|
|
|
dereferencable_scalar:
|
2016-07-07 03:15:05 +08:00
|
|
|
T_ARRAY '(' array_pair_list ')' { $$ = $3; $$->attr = ZEND_ARRAY_SYNTAX_LONG; }
|
|
|
|
| '[' array_pair_list ']' { $$ = $2; $$->attr = ZEND_ARRAY_SYNTAX_SHORT; }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
|
2014-05-31 22:44:53 +08:00
|
|
|
;
|
|
|
|
|
2014-06-27 04:04:09 +08:00
|
|
|
scalar:
|
2014-08-22 06:40:07 +08:00
|
|
|
T_LNUMBER { $$ = $1; }
|
|
|
|
| T_DNUMBER { $$ = $1; }
|
2014-08-27 04:47:11 +08:00
|
|
|
| T_LINE { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_LINE); }
|
|
|
|
| T_FILE { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_FILE); }
|
|
|
|
| T_DIR { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_DIR); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_TRAIT_C { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_TRAIT_C); }
|
|
|
|
| T_METHOD_C { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_METHOD_C); }
|
|
|
|
| T_FUNC_C { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_FUNC_C); }
|
|
|
|
| T_NS_C { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_NS_C); }
|
|
|
|
| T_CLASS_C { $$ = zend_ast_create_ex(ZEND_AST_MAGIC_CONST, T_CLASS_C); }
|
|
|
|
| T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2; }
|
2014-06-27 04:04:09 +08:00
|
|
|
| T_START_HEREDOC T_END_HEREDOC
|
2015-06-29 21:44:54 +08:00
|
|
|
{ $$ = zend_ast_create_zval_from_str(ZSTR_EMPTY_ALLOC()); }
|
2014-08-30 02:52:26 +08:00
|
|
|
| '"' encaps_list '"' { $$ = $2; }
|
|
|
|
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; }
|
2014-08-22 06:40:07 +08:00
|
|
|
| dereferencable_scalar { $$ = $1; }
|
|
|
|
| constant { $$ = $1; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2014-08-17 04:13:33 +08:00
|
|
|
constant:
|
2014-08-22 06:40:07 +08:00
|
|
|
name { $$ = zend_ast_create(ZEND_AST_CONST, $1); }
|
2015-03-09 13:24:50 +08:00
|
|
|
| class_name T_PAAMAYIM_NEKUDOTAYIM identifier
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_CLASS_CONST, $1, $3); }
|
2015-03-09 13:24:50 +08:00
|
|
|
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_CLASS_CONST, $1, $3); }
|
2014-08-17 04:13:33 +08:00
|
|
|
;
|
1999-04-08 02:10:10 +08:00
|
|
|
|
2014-08-30 00:51:58 +08:00
|
|
|
optional_expr:
|
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| expr { $$ = $1; }
|
|
|
|
;
|
|
|
|
|
2007-09-27 08:32:40 +08:00
|
|
|
variable_class_name:
|
2014-08-22 06:40:07 +08:00
|
|
|
dereferencable { $$ = $1; }
|
2007-09-27 08:32:40 +08:00
|
|
|
;
|
2001-12-14 06:21:50 +08:00
|
|
|
|
2014-05-31 05:44:30 +08:00
|
|
|
dereferencable:
|
2014-08-22 06:40:07 +08:00
|
|
|
variable { $$ = $1; }
|
|
|
|
| '(' expr ')' { $$ = $2; }
|
|
|
|
| dereferencable_scalar { $$ = $1; }
|
2014-05-31 05:44:30 +08:00
|
|
|
;
|
|
|
|
|
2014-05-31 23:18:37 +08:00
|
|
|
callable_expr:
|
2014-08-22 06:40:07 +08:00
|
|
|
callable_variable { $$ = $1; }
|
|
|
|
| '(' expr ')' { $$ = $2; }
|
|
|
|
| dereferencable_scalar { $$ = $1; }
|
2014-05-31 23:18:37 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
callable_variable:
|
2014-05-31 06:02:51 +08:00
|
|
|
simple_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_VAR, $1); }
|
2014-08-30 00:51:58 +08:00
|
|
|
| dereferencable '[' optional_expr ']'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
|
2014-08-30 00:51:58 +08:00
|
|
|
| constant '[' optional_expr ']'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
|
2014-05-31 06:02:51 +08:00
|
|
|
| dereferencable '{' expr '}'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
|
2015-03-09 13:24:50 +08:00
|
|
|
| dereferencable T_OBJECT_OPERATOR property_name argument_list
|
2014-08-30 02:52:26 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_METHOD_CALL, $1, $3, $4); }
|
2014-08-22 06:40:07 +08:00
|
|
|
| function_call { $$ = $1; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
2006-05-12 05:07:39 +08:00
|
|
|
|
2014-05-31 05:36:30 +08:00
|
|
|
variable:
|
2014-06-07 19:06:53 +08:00
|
|
|
callable_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = $1; }
|
2014-06-07 19:06:53 +08:00
|
|
|
| static_member
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = $1; }
|
2015-03-09 13:24:50 +08:00
|
|
|
| dereferencable T_OBJECT_OPERATOR property_name
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_PROP, $1, $3); }
|
2014-05-31 04:33:03 +08:00
|
|
|
;
|
|
|
|
|
2014-05-30 22:31:10 +08:00
|
|
|
simple_variable:
|
2014-08-30 02:52:26 +08:00
|
|
|
T_VARIABLE { $$ = $1; }
|
|
|
|
| '$' '{' expr '}' { $$ = $3; }
|
|
|
|
| '$' simple_variable { $$ = zend_ast_create(ZEND_AST_VAR, $2); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2014-05-31 05:44:30 +08:00
|
|
|
static_member:
|
2014-06-07 19:06:53 +08:00
|
|
|
class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_STATIC_PROP, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_STATIC_PROP, $1, $3); }
|
2014-05-31 05:44:30 +08:00
|
|
|
;
|
|
|
|
|
2014-05-31 06:37:03 +08:00
|
|
|
new_variable:
|
|
|
|
simple_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_VAR, $1); }
|
2014-08-30 00:51:58 +08:00
|
|
|
| new_variable '[' optional_expr ']'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| new_variable '{' expr '}'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); }
|
2015-03-09 13:24:50 +08:00
|
|
|
| new_variable T_OBJECT_OPERATOR property_name
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_PROP, $1, $3); }
|
2014-06-06 23:05:14 +08:00
|
|
|
| class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_STATIC_PROP, $1, $3); }
|
2014-06-06 23:05:14 +08:00
|
|
|
| new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_STATIC_PROP, $1, $3); }
|
2014-05-31 06:37:03 +08:00
|
|
|
;
|
2014-05-31 05:44:30 +08:00
|
|
|
|
2014-06-01 02:58:44 +08:00
|
|
|
member_name:
|
2015-03-09 13:24:50 +08:00
|
|
|
identifier { $$ = $1; }
|
|
|
|
| '{' expr '}' { $$ = $2; }
|
|
|
|
| simple_variable { $$ = zend_ast_create(ZEND_AST_VAR, $1); }
|
|
|
|
;
|
|
|
|
|
|
|
|
property_name:
|
|
|
|
T_STRING { $$ = $1; }
|
2014-08-22 06:40:07 +08:00
|
|
|
| '{' expr '}' { $$ = $2; }
|
|
|
|
| simple_variable { $$ = zend_ast_create(ZEND_AST_VAR, $1); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
array_pair_list:
|
2016-06-14 23:05:17 +08:00
|
|
|
non_empty_array_pair_list
|
|
|
|
{ /* allow single trailing comma */ $$ = zend_ast_list_rtrim($1); }
|
2016-06-14 00:21:14 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
possible_array_pair:
|
|
|
|
/* empty */ { $$ = NULL; }
|
|
|
|
| array_pair { $$ = $1; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
non_empty_array_pair_list:
|
2016-06-14 00:21:14 +08:00
|
|
|
non_empty_array_pair_list ',' possible_array_pair
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $3); }
|
2016-06-14 00:21:14 +08:00
|
|
|
| possible_array_pair
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_ARRAY, $1); }
|
2014-06-19 19:57:29 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
array_pair:
|
|
|
|
expr T_DOUBLE_ARROW expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_ARRAY_ELEM, $3, $1); }
|
2016-04-05 06:34:42 +08:00
|
|
|
| expr
|
|
|
|
{ $$ = zend_ast_create(ZEND_AST_ARRAY_ELEM, $1, NULL); }
|
2014-06-19 19:57:29 +08:00
|
|
|
| expr T_DOUBLE_ARROW '&' variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_ARRAY_ELEM, 1, $4, $1); }
|
2014-06-19 19:57:29 +08:00
|
|
|
| '&' variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_ARRAY_ELEM, 1, $2, NULL); }
|
2016-04-05 06:34:42 +08:00
|
|
|
| expr T_DOUBLE_ARROW T_LIST '(' array_pair_list ')'
|
2016-07-07 03:15:05 +08:00
|
|
|
{ $5->attr = ZEND_ARRAY_SYNTAX_LIST;
|
|
|
|
$$ = zend_ast_create(ZEND_AST_ARRAY_ELEM, $5, $1); }
|
2016-04-05 06:34:42 +08:00
|
|
|
| T_LIST '(' array_pair_list ')'
|
2016-07-07 03:15:05 +08:00
|
|
|
{ $3->attr = ZEND_ARRAY_SYNTAX_LIST;
|
|
|
|
$$ = zend_ast_create(ZEND_AST_ARRAY_ELEM, $3, NULL); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
encaps_list:
|
2014-06-07 19:06:53 +08:00
|
|
|
encaps_list encaps_var
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $2); }
|
2014-06-22 02:03:29 +08:00
|
|
|
| encaps_list T_ENCAPSED_AND_WHITESPACE
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_list_add($1, $2); }
|
2014-06-22 02:03:29 +08:00
|
|
|
| encaps_var
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(1, ZEND_AST_ENCAPS_LIST, $1); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| T_ENCAPSED_AND_WHITESPACE encaps_var
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_list(2, ZEND_AST_ENCAPS_LIST, $1, $2); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
encaps_var:
|
2014-06-07 19:06:53 +08:00
|
|
|
T_VARIABLE
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_VAR, $1); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| T_VARIABLE '[' encaps_var_offset ']'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DIM,
|
|
|
|
zend_ast_create(ZEND_AST_VAR, $1), $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| T_VARIABLE T_OBJECT_OPERATOR T_STRING
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_PROP,
|
|
|
|
zend_ast_create(ZEND_AST_VAR, $1), $3); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| T_DOLLAR_OPEN_CURLY_BRACES expr '}'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_VAR, $2); }
|
2014-06-22 02:11:31 +08:00
|
|
|
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_VAR, $2); }
|
2014-06-07 19:06:53 +08:00
|
|
|
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_DIM,
|
|
|
|
zend_ast_create(ZEND_AST_VAR, $2), $4); }
|
|
|
|
| T_CURLY_OPEN variable '}' { $$ = $2; }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
encaps_var_offset:
|
2016-12-11 20:31:37 +08:00
|
|
|
T_STRING { $$ = $1; }
|
|
|
|
| T_NUM_STRING { $$ = $1; }
|
|
|
|
| '-' T_NUM_STRING { $$ = zend_negate_num_string($2); }
|
|
|
|
| T_VARIABLE { $$ = zend_ast_create(ZEND_AST_VAR, $1); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
internal_functions_in_yacc:
|
2017-10-08 01:57:07 +08:00
|
|
|
T_ISSET '(' isset_variables possible_comma ')' { $$ = $3; }
|
2014-08-22 06:40:07 +08:00
|
|
|
| T_EMPTY '(' expr ')' { $$ = zend_ast_create(ZEND_AST_EMPTY, $3); }
|
2014-06-19 19:57:29 +08:00
|
|
|
| T_INCLUDE expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_INCLUDE_OR_EVAL, ZEND_INCLUDE, $2); }
|
2014-06-19 19:57:29 +08:00
|
|
|
| T_INCLUDE_ONCE expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_INCLUDE_OR_EVAL, ZEND_INCLUDE_ONCE, $2); }
|
2014-06-19 19:57:29 +08:00
|
|
|
| T_EVAL '(' expr ')'
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_INCLUDE_OR_EVAL, ZEND_EVAL, $3); }
|
2014-06-19 19:57:29 +08:00
|
|
|
| T_REQUIRE expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_INCLUDE_OR_EVAL, ZEND_REQUIRE, $2); }
|
2014-06-19 19:57:29 +08:00
|
|
|
| T_REQUIRE_ONCE expr
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create_ex(ZEND_AST_INCLUDE_OR_EVAL, ZEND_REQUIRE_ONCE, $2); }
|
1999-04-08 02:10:10 +08:00
|
|
|
;
|
|
|
|
|
2001-03-20 03:31:14 +08:00
|
|
|
isset_variables:
|
2014-08-22 06:40:07 +08:00
|
|
|
isset_variable { $$ = $1; }
|
2014-06-19 19:57:29 +08:00
|
|
|
| isset_variables ',' isset_variable
|
2014-08-22 06:40:07 +08:00
|
|
|
{ $$ = zend_ast_create(ZEND_AST_AND, $1, $3); }
|
2012-04-12 17:54:52 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
isset_variable:
|
2014-08-22 06:40:07 +08:00
|
|
|
expr { $$ = zend_ast_create(ZEND_AST_ISSET, $1); }
|
2006-05-12 05:07:39 +08:00
|
|
|
;
|
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)
|
|
|
|
{
|
2015-10-13 04:05:19 +08:00
|
|
|
/* CG(parse_error) states:
|
|
|
|
* 0 => yyres = NULL, yystr is the unexpected token
|
|
|
|
* 1 => yyres = NULL, yystr is one of the expected tokens
|
|
|
|
* 2 => yyres != NULL, yystr is the unexpected token
|
|
|
|
* 3 => yyres != NULL, yystr is one of the expected tokens
|
|
|
|
*/
|
|
|
|
if (yyres && CG(parse_error) < 2) {
|
|
|
|
CG(parse_error) = 2;
|
2011-06-24 07:00:53 +08:00
|
|
|
}
|
2015-10-13 04:05:19 +08:00
|
|
|
|
|
|
|
if (CG(parse_error) % 2 == 0) {
|
|
|
|
/* The unexpected token */
|
2015-10-16 03:23:29 +08:00
|
|
|
char buffer[120];
|
|
|
|
const unsigned char *end, *str, *tok1 = NULL, *tok2 = NULL;
|
|
|
|
unsigned int len = 0, toklen = 0, yystr_len;
|
|
|
|
|
2015-10-13 04:05:19 +08:00
|
|
|
CG(parse_error)++;
|
2015-10-16 03:23:29 +08:00
|
|
|
|
|
|
|
if (LANG_SCNG(yy_text)[0] == 0 &&
|
|
|
|
LANG_SCNG(yy_leng) == 1 &&
|
|
|
|
memcmp(yystr, "\"end of file\"", sizeof("\"end of file\"") - 1) == 0) {
|
2015-10-13 04:05:19 +08:00
|
|
|
if (yyres) {
|
|
|
|
yystpcpy(yyres, "end of file");
|
|
|
|
}
|
2015-10-16 03:23:29 +08:00
|
|
|
return sizeof("end of file")-1;
|
2015-01-03 17:22:58 +08:00
|
|
|
}
|
2015-10-16 03:23:29 +08:00
|
|
|
|
|
|
|
str = LANG_SCNG(yy_text);
|
|
|
|
end = memchr(str, '\n', LANG_SCNG(yy_leng));
|
|
|
|
yystr_len = (unsigned int)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);
|
|
|
|
}
|
2015-10-13 04:05:19 +08:00
|
|
|
if (yyres) {
|
|
|
|
if (toklen) {
|
|
|
|
snprintf(buffer, sizeof(buffer), "'%.*s' %.*s", len, str, toklen, tok1);
|
|
|
|
} else {
|
|
|
|
snprintf(buffer, sizeof(buffer), "'%.*s'", len, str);
|
|
|
|
}
|
|
|
|
yystpcpy(yyres, buffer);
|
2015-10-16 03:23:29 +08:00
|
|
|
}
|
|
|
|
return len + (toklen ? toklen + 1 : 0) + 2;
|
2015-01-03 17:22:58 +08:00
|
|
|
}
|
2015-10-13 04:05:19 +08:00
|
|
|
|
|
|
|
/* One of the expected tokens */
|
|
|
|
if (!yyres) {
|
|
|
|
return yystrlen(yystr) - (*yystr == '"' ? 2 : 0);
|
|
|
|
}
|
|
|
|
|
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:
|
2017-07-05 00:12:45 +08:00
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
2003-02-01 09:49:15 +08:00
|
|
|
*/
|