Skip to content

Instantly share code, notes, and snippets.

@do-aki
Created December 5, 2011 01:56
Show Gist options
  • Save do-aki/1431981 to your computer and use it in GitHub Desktop.
Save do-aki/1431981 to your computer and use it in GitHub Desktop.
Difference between 5.3.8 and 5.4.0RC2
--- php-5.3.8/Zend/zend_language_parser.y Sun Jun 12 10:43:10 2011
+++ php-5.4.0RC2/Zend/zend_language_parser.y Tue Nov 29 23:15:18 2011
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_language_parser.y 312076 2011-06-12 01:43:10Z felipe $ */
+/* $Id: zend_language_parser.y 318823 2011-11-06 13:25:45Z felipe $ */
/*
* LALR shift/reduce conflicts and how they are resolved:
@@ -35,6 +35,9 @@
#include "zend_API.h"
#include "zend_constants.h"
+#define YYSIZE_T size_t
+#define yytnamerr zend_yytnamerr
+static YYSIZE_T zend_yytnamerr(char*, const char*);
#define YYERROR_VERBOSE
#define YYSTYPE znode
@@ -47,107 +50,163 @@
%}
%pure_parser
-%expect 2
+%expect 3
+%token END 0 "end of file"
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
+%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)"
%left ','
%left T_LOGICAL_OR
+%token T_LOGICAL_OR "or (T_LOGICAL_OR)"
%left T_LOGICAL_XOR
+%token T_LOGICAL_XOR "xor (T_LOGICAL_XOR)"
%left T_LOGICAL_AND
+%token T_LOGICAL_AND "and (T_LOGICAL_AND)"
%right T_PRINT
+%token T_PRINT "print (T_PRINT)"
%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
+%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)"
%left '?' ':'
%left T_BOOLEAN_OR
+%token T_BOOLEAN_OR "|| (T_BOOLEAN_OR)"
%left T_BOOLEAN_AND
+%token T_BOOLEAN_AND "&& (T_BOOLEAN_AND)"
%left '|'
%left '^'
%left '&'
%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
+%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)"
%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
+%token T_IS_SMALLER_OR_EQUAL "<= (T_IS_SMALLER_OR_EQUAL)"
+%token T_IS_GREATER_OR_EQUAL ">= (T_IS_GREATER_OR_EQUAL)"
%left T_SL T_SR
+%token T_SL "<< (T_SL)"
+%token T_SR ">> (T_SR)"
%left '+' '-' '.'
%left '*' '/' '%'
%right '!'
%nonassoc T_INSTANCEOF
+%token T_INSTANCEOF "instanceof (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 '@'
+%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)"
%right '['
%nonassoc T_NEW T_CLONE
-%token T_EXIT
-%token T_IF
+%token T_NEW "new (T_NEW)"
+%token T_CLONE "clone (T_CLONE)"
+%token T_EXIT "exit (T_EXIT)"
+%token T_IF "if (T_IF)"
%left T_ELSEIF
+%token T_ELSEIF "elseif (T_ELSEIF)"
%left T_ELSE
+%token T_ELSE "else (T_ELSE)"
%left T_ENDIF
-%token T_LNUMBER
-%token T_DNUMBER
-%token T_STRING
-%token T_STRING_VARNAME
-%token T_VARIABLE
-%token T_NUM_STRING
+%token T_ENDIF "endif (T_ENDIF)"
+%token T_LNUMBER "integer number (T_LNUMBER)"
+%token T_DNUMBER "floating-point number (T_DNUMBER)"
+%token T_STRING "identifier (T_STRING)"
+%token T_STRING_VARNAME "variable name (T_STRING_VARNAME)"
+%token T_VARIABLE "variable (T_VARIABLE)"
+%token T_NUM_STRING "number (T_NUM_STRING)"
%token T_INLINE_HTML
%token T_CHARACTER
%token T_BAD_CHARACTER
-%token T_ENCAPSED_AND_WHITESPACE
-%token T_CONSTANT_ENCAPSED_STRING
-%token T_ECHO
-%token T_DO
-%token T_WHILE
-%token T_ENDWHILE
-%token T_FOR
-%token T_ENDFOR
-%token T_FOREACH
-%token T_ENDFOREACH
-%token T_DECLARE
-%token T_ENDDECLARE
-%token T_AS
-%token T_SWITCH
-%token T_ENDSWITCH
-%token T_CASE
-%token T_DEFAULT
-%token T_BREAK
-%token T_CONTINUE
-%token T_GOTO
-%token T_FUNCTION
-%token T_CONST
-%token T_RETURN
-%token T_TRY
-%token T_CATCH
-%token T_THROW
-%token T_USE
-%token T_GLOBAL
+%token T_ENCAPSED_AND_WHITESPACE "quoted-string and whitespace (T_ENCAPSED_AND_WHITESPACE)"
+%token T_CONSTANT_ENCAPSED_STRING "quoted-string (T_CONSTANT_ENCAPSED_STRING)"
+%token T_ECHO "echo (T_ECHO)"
+%token T_DO "do (T_DO)"
+%token T_WHILE "while (T_WHILE)"
+%token T_ENDWHILE "endwhile (T_ENDWHILE)"
+%token T_FOR "for (T_FOR)"
+%token T_ENDFOR "endfor (T_ENDFOR)"
+%token T_FOREACH "foreach (T_FOREACH)"
+%token T_ENDFOREACH "endforeach (T_ENDFOREACH)"
+%token T_DECLARE "declare (T_DECLARE)"
+%token T_ENDDECLARE "enddeclare (T_ENDDECLARE)"
+%token T_AS "as (T_AS)"
+%token T_SWITCH "switch (T_SWITCH)"
+%token T_ENDSWITCH "endswitch (T_ENDSWITCH)"
+%token T_CASE "case (T_CASE)"
+%token T_DEFAULT "default (T_DEFAULT)"
+%token T_BREAK "break (T_BREAK)"
+%token T_CONTINUE "continue (T_CONTINUE)"
+%token T_GOTO "goto (T_GOTO)"
+%token T_FUNCTION "function (T_FUNCTION)"
+%token T_CONST "const (T_CONST)"
+%token T_RETURN "return (T_RETURN)"
+%token T_TRY "try (T_TRY)"
+%token T_CATCH "catch (T_CATCH)"
+%token T_THROW "throw (T_THROW)"
+%token T_USE "use (T_USE)"
+%token T_INSTEADOF "insteadof (T_INSTEADOF)"
+%token T_GLOBAL "global (T_GLOBAL)"
%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
-%token T_VAR
-%token T_UNSET
-%token T_ISSET
-%token T_EMPTY
-%token T_HALT_COMPILER
-%token T_CLASS
-%token T_INTERFACE
-%token T_EXTENDS
-%token T_IMPLEMENTS
-%token T_OBJECT_OPERATOR
-%token T_DOUBLE_ARROW
-%token T_LIST
-%token T_ARRAY
-%token T_CLASS_C
-%token T_METHOD_C
-%token T_FUNC_C
-%token T_LINE
-%token T_FILE
-%token T_COMMENT
-%token T_DOC_COMMENT
-%token T_OPEN_TAG
-%token T_OPEN_TAG_WITH_ECHO
-%token T_CLOSE_TAG
-%token T_WHITESPACE
-%token T_START_HEREDOC
-%token T_END_HEREDOC
-%token T_DOLLAR_OPEN_CURLY_BRACES
-%token T_CURLY_OPEN
-%token T_PAAMAYIM_NEKUDOTAYIM
-%token T_NAMESPACE
-%token T_NS_C
-%token T_DIR
-%token T_NS_SEPARATOR
+%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)"
+%token T_CALLABLE "callable (T_CALLABLE)"
+%token T_CLASS_C "__CLASS__ (T_CLASS_C)"
+%token T_TRAIT_C "__TRAIT__ (T_TRAIT_C)"
+%token T_METHOD_C "__METHOD__ (T_METHOD_C)"
+%token T_FUNC_C "__FUNCTION__ (T_FUNC_C)"
+%token T_LINE "__LINE__ (T_LINE)"
+%token T_FILE "__FILE__ (T_FILE)"
+%token T_COMMENT "comment (T_COMMENT)"
+%token T_DOC_COMMENT "doc comment (T_DOC_COMMENT)"
+%token T_OPEN_TAG "open tag (T_OPEN_TAG)"
+%token T_OPEN_TAG_WITH_ECHO "open tag with echo (T_OPEN_TAG_WITH_ECHO)"
+%token T_CLOSE_TAG "close tag (T_CLOSE_TAG)"
+%token T_WHITESPACE "whitespace (T_WHITESPACE)"
+%token T_START_HEREDOC "heredoc start (T_START_HEREDOC)"
+%token T_END_HEREDOC "heredoc end (T_END_HEREDOC)"
+%token T_DOLLAR_OPEN_CURLY_BRACES "${ (T_DOLLAR_OPEN_CURLY_BRACES)"
+%token T_CURLY_OPEN "{$ (T_CURLY_OPEN)"
+%token T_PAAMAYIM_NEKUDOTAYIM ":: (T_PAAMAYIM_NEKUDOTAYIM)"
+%token T_NAMESPACE "namespace (T_NAMESPACE)"
+%token T_NS_C "__NAMESPACE__ (T_NS_C)"
+%token T_DIR "__DIR__ (T_DIR)"
+%token T_NS_SEPARATOR "\\ (T_NS_SEPARATOR)"
%% /* Rules */
@@ -219,12 +278,12 @@
'{' inner_statement_list '}'
| T_IF '(' expr ')' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } statement { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } elseif_list else_single { zend_do_if_end(TSRMLS_C); }
| T_IF '(' expr ')' ':' { zend_do_if_cond(&$3, &$4 TSRMLS_CC); } inner_statement_list { zend_do_if_after_statement(&$4, 1 TSRMLS_CC); } new_elseif_list new_else_single T_ENDIF ';' { zend_do_if_end(TSRMLS_C); }
- | T_WHILE '(' { $1.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' { zend_do_while_cond(&$4, &$5 TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$5 TSRMLS_CC); }
- | T_DO { $1.u.opline_num = get_next_op_number(CG(active_op_array)); zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE '(' { $5.u.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' ';' { zend_do_do_while_end(&$1, &$5, &$7 TSRMLS_CC); }
+ | T_WHILE '(' { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' { zend_do_while_cond(&$4, &$5 TSRMLS_CC); } while_statement { zend_do_while_end(&$1, &$5 TSRMLS_CC); }
+ | T_DO { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_do_while_begin(TSRMLS_C); } statement T_WHILE '(' { $5.u.op.opline_num = get_next_op_number(CG(active_op_array)); } expr ')' ';' { zend_do_do_while_end(&$1, &$5, &$7 TSRMLS_CC); }
| T_FOR
'('
for_expr
- ';' { zend_do_free(&$3 TSRMLS_CC); $4.u.opline_num = get_next_op_number(CG(active_op_array)); }
+ ';' { zend_do_free(&$3 TSRMLS_CC); $4.u.op.opline_num = get_next_op_number(CG(active_op_array)); }
for_expr
';' { zend_do_extended_info(TSRMLS_C); zend_do_for_cond(&$6, &$7 TSRMLS_CC); }
for_expr
@@ -252,7 +311,7 @@
{ zend_do_foreach_begin(&$1, &$2, &$3, &$4, 0 TSRMLS_CC); }
variable foreach_optional_arg ')' { zend_check_writable_variable(&$6); zend_do_foreach_cont(&$1, &$2, &$4, &$6, &$7 TSRMLS_CC); }
foreach_statement { zend_do_foreach_end(&$1, &$4 TSRMLS_CC); }
- | T_DECLARE { $1.u.opline_num = get_next_op_number(CG(active_op_array)); zend_do_declare_begin(TSRMLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end(&$1 TSRMLS_CC); }
+ | T_DECLARE { $1.u.op.opline_num = get_next_op_number(CG(active_op_array)); zend_do_declare_begin(TSRMLS_C); } '(' declare_list ')' declare_statement { zend_do_declare_end(&$1 TSRMLS_CC); }
| ';' /* empty statement */
| T_TRY { zend_do_try(&$1 TSRMLS_CC); } '{' inner_statement_list '}'
T_CATCH '(' { zend_initialize_try_catch_element(&$1 TSRMLS_CC); }
@@ -267,7 +326,7 @@
additional_catches:
non_empty_additional_catches { $$ = $1; }
- | /* empty */ { $$.u.opline_num = -1; }
+ | /* empty */ { $$.u.op.opline_num = -1; }
;
non_empty_additional_catches:
@@ -277,7 +336,7 @@
additional_catch:
- T_CATCH '(' fully_qualified_class_name { $$.u.opline_num = get_next_op_number(CG(active_op_array)); } T_VARIABLE ')' { zend_do_begin_catch(&$1, &$3, &$5, NULL TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
+ T_CATCH '(' fully_qualified_class_name { $$.u.op.opline_num = get_next_op_number(CG(active_op_array)); } T_VARIABLE ')' { zend_do_begin_catch(&$1, &$3, &$5, NULL TSRMLS_CC); } '{' inner_statement_list '}' { zend_do_end_catch(&$1 TSRMLS_CC); }
;
@@ -327,9 +386,10 @@
class_entry_type:
- T_CLASS { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = 0; }
- | T_ABSTRACT T_CLASS { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; }
- | T_FINAL T_CLASS { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = ZEND_ACC_FINAL_CLASS; }
+ T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = 0; }
+ | T_ABSTRACT T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; }
+ | T_TRAIT { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_TRAIT; }
+ | T_FINAL T_CLASS { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_FINAL_CLASS; }
;
extends_from:
@@ -338,7 +398,7 @@
;
interface_entry:
- T_INTERFACE { $$.u.opline_num = CG(zend_lineno); $$.u.EA.type = ZEND_ACC_INTERFACE; }
+ T_INTERFACE { $$.u.op.opline_num = CG(zend_lineno); $$.EA = ZEND_ACC_INTERFACE; }
;
interface_extends_list:
@@ -364,7 +424,7 @@
foreach_variable:
variable { zend_check_writable_variable(&$1); $$ = $1; }
- | '&' variable { zend_check_writable_variable(&$2); $$ = $2; $$.u.EA.type |= ZEND_PARSED_REFERENCE_VARIABLE; }
+ | '&' variable { zend_check_writable_variable(&$2); $$ = $2; $$.EA |= ZEND_PARSED_REFERENCE_VARIABLE; }
;
for_statement:
@@ -450,21 +510,22 @@
non_empty_parameter_list:
- optional_class_type T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$2, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$1, &$2, 0 TSRMLS_CC); }
- | optional_class_type '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$3, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$1, &$3, 1 TSRMLS_CC); }
- | optional_class_type '&' T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$3, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$5, &$1, &$3, 1 TSRMLS_CC); }
- | optional_class_type T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$2, 0 TSRMLS_CC); $$.op_type = IS_CONST; Z_LVAL($$.u.constant)=1; Z_TYPE($$.u.constant)=IS_LONG; INIT_PZVAL(&$$.u.constant); zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$4, &$1, &$2, 0 TSRMLS_CC); }
- | non_empty_parameter_list ',' optional_class_type T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$4, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$3, &$4, 0 TSRMLS_CC); }
- | non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE { znode tmp; fetch_simple_variable(&tmp, &$5, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV, &tmp, &$$, NULL, &$3, &$5, 1 TSRMLS_CC); }
- | non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$5, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$7, &$3, &$5, 1 TSRMLS_CC); }
- | non_empty_parameter_list ',' optional_class_type T_VARIABLE '=' static_scalar { znode tmp; fetch_simple_variable(&tmp, &$4, 0 TSRMLS_CC); $$=$1; Z_LVAL($$.u.constant)++; zend_do_receive_arg(ZEND_RECV_INIT, &tmp, &$$, &$6, &$3, &$4, 0 TSRMLS_CC); }
+ optional_class_type T_VARIABLE { $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV, &$2, &$$, NULL, &$1, 0 TSRMLS_CC); }
+ | optional_class_type '&' T_VARIABLE { $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV, &$3, &$$, NULL, &$1, 1 TSRMLS_CC); }
+ | optional_class_type '&' T_VARIABLE '=' static_scalar { $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV_INIT, &$3, &$$, &$5, &$1, 1 TSRMLS_CC); }
+ | optional_class_type T_VARIABLE '=' static_scalar { $$.op_type = IS_UNUSED; $$.u.op.num=1; zend_do_receive_arg(ZEND_RECV_INIT, &$2, &$$, &$4, &$1, 0 TSRMLS_CC); }
+ | non_empty_parameter_list ',' optional_class_type T_VARIABLE { $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV, &$4, &$$, NULL, &$3, 0 TSRMLS_CC); }
+ | non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE { $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV, &$5, &$$, NULL, &$3, 1 TSRMLS_CC); }
+ | non_empty_parameter_list ',' optional_class_type '&' T_VARIABLE '=' static_scalar { $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV_INIT, &$5, &$$, &$7, &$3, 1 TSRMLS_CC); }
+ | non_empty_parameter_list ',' optional_class_type T_VARIABLE '=' static_scalar { $$=$1; $$.u.op.num++; zend_do_receive_arg(ZEND_RECV_INIT, &$4, &$$, &$6, &$3, 0 TSRMLS_CC); }
;
optional_class_type:
/* empty */ { $$.op_type = IS_UNUSED; }
+ | T_ARRAY { $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_ARRAY; }
+ | T_CALLABLE { $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_CALLABLE; }
| fully_qualified_class_name { $$ = $1; }
- | T_ARRAY { $$.op_type = IS_CONST; Z_TYPE($$.u.constant)=IS_NULL;}
;
@@ -514,10 +575,67 @@
class_statement:
variable_modifiers { CG(access_type) = Z_LVAL($1.u.constant); } class_variable_declaration ';'
| class_constant_declaration ';'
+ | trait_use_statement
| method_modifiers function is_reference T_STRING { zend_do_begin_function_declaration(&$2, &$4, 1, $3.op_type, &$1 TSRMLS_CC); } '('
parameter_list ')' method_body { zend_do_abstract_method(&$4, &$1, &$9 TSRMLS_CC); zend_do_end_function_declaration(&$2 TSRMLS_CC); }
;
+trait_use_statement:
+ T_USE trait_list trait_adaptations
+;
+
+trait_list:
+ fully_qualified_class_name { zend_do_implements_trait(&$1 TSRMLS_CC); }
+ | trait_list ',' fully_qualified_class_name { zend_do_implements_trait(&$3 TSRMLS_CC); }
+;
+
+trait_adaptations:
+ ';'
+ | '{' trait_adaptation_list '}'
+;
+
+trait_adaptation_list:
+ /* empty */
+ | non_empty_trait_adaptation_list
+;
+
+non_empty_trait_adaptation_list:
+ trait_adaptation_statement
+ | non_empty_trait_adaptation_list trait_adaptation_statement
+;
+
+trait_adaptation_statement:
+ trait_precedence ';' { zend_add_trait_precedence(&$1 TSRMLS_CC); }
+ | trait_alias ';' { zend_add_trait_alias(&$1 TSRMLS_CC); }
+;
+
+trait_precedence:
+ trait_method_reference_fully_qualified T_INSTEADOF trait_reference_list { zend_prepare_trait_precedence(&$$, &$1, &$3 TSRMLS_CC); }
+;
+
+trait_reference_list:
+ fully_qualified_class_name { zend_resolve_class_name(&$1, ZEND_FETCH_CLASS_GLOBAL, 1 TSRMLS_CC); zend_init_list(&$$.u.op.ptr, Z_STRVAL($1.u.constant) TSRMLS_CC); }
+ | trait_reference_list ',' fully_qualified_class_name { zend_resolve_class_name(&$3, ZEND_FETCH_CLASS_GLOBAL, 1 TSRMLS_CC); zend_add_to_list(&$1.u.op.ptr, Z_STRVAL($3.u.constant) TSRMLS_CC); $$ = $1; }
+;
+
+trait_method_reference:
+ T_STRING { zend_prepare_reference(&$$, NULL, &$1 TSRMLS_CC); }
+ | trait_method_reference_fully_qualified { $$ = $1; }
+;
+
+trait_method_reference_fully_qualified:
+ fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_prepare_reference(&$$, &$1, &$3 TSRMLS_CC); }
+;
+
+trait_alias:
+ trait_method_reference T_AS trait_modifiers T_STRING { zend_prepare_trait_alias(&$$, &$1, &$3, &$4 TSRMLS_CC); }
+ | trait_method_reference T_AS member_modifier { zend_prepare_trait_alias(&$$, &$1, &$3, NULL TSRMLS_CC); }
+;
+
+trait_modifiers:
+ /* empty */ { Z_LVAL($$.u.constant) = 0x0; } /* No change of methods visibility */
+ | member_modifier { $$ = $1; } /* REM: Keep in mind, there are not only visibility modifiers */
+;
method_body:
';' /* abstract method */ { Z_LVAL($$.u.constant) = ZEND_ACC_ABSTRACT; }
@@ -576,12 +694,37 @@
| expr { $$ = $1; }
;
+chaining_method_or_property:
+ chaining_method_or_property variable_property { $$.EA = $2.EA; }
+ | variable_property { $$.EA = $1.EA; }
+;
+
+chaining_dereference:
+ chaining_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
+ | '[' dim_offset ']' { zend_do_pop_object(&$1 TSRMLS_CC); fetch_array_dim(&$$, &$1, &$2 TSRMLS_CC); }
+;
+
+chaining_instance_call:
+ chaining_dereference { zend_do_push_object(&$1 TSRMLS_CC); } chaining_method_or_property { $$ = $3; }
+ | chaining_dereference { zend_do_push_object(&$1 TSRMLS_CC); $$ = $1; }
+ | chaining_method_or_property { $$ = $1; }
+;
+
+instance_call:
+ /* empty */ { $$ = $0; }
+ | { zend_do_push_object(&$0 TSRMLS_CC); zend_do_begin_variable_parse(TSRMLS_C); }
+ chaining_instance_call { zend_do_pop_object(&$$ TSRMLS_CC); zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC); }
+;
+
+new_expr:
+ T_NEW class_name_reference { zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$1, &$2 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$$, &$1, &$4 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
+;
+
expr_without_variable:
T_LIST '(' { zend_do_list_init(TSRMLS_C); } assignment_list ')' '=' expr { zend_do_list_end(&$$, &$7 TSRMLS_CC); }
| variable '=' expr { zend_check_writable_variable(&$1); zend_do_assign(&$$, &$1, &$3 TSRMLS_CC); }
| variable '=' '&' variable { zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$4, BP_VAR_W, 1 TSRMLS_CC); zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); zend_do_assign_ref(&$$, &$1, &$4 TSRMLS_CC); }
- | variable '=' '&' T_NEW class_name_reference { zend_error(E_DEPRECATED, "Assigning the return value of new by reference is deprecated"); zend_check_writable_variable(&$1); zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$4, &$5 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$3, &$4, &$7 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); $3.u.EA.type = ZEND_PARSED_NEW; zend_do_assign_ref(&$$, &$1, &$3 TSRMLS_CC); }
- | T_NEW class_name_reference { zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$1, &$2 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$$, &$1, &$4 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
+ | variable '=' '&' T_NEW class_name_reference { zend_error(E_DEPRECATED, "Assigning the return value of new by reference is deprecated"); zend_check_writable_variable(&$1); zend_do_extended_fcall_begin(TSRMLS_C); zend_do_begin_new_object(&$4, &$5 TSRMLS_CC); } ctor_arguments { zend_do_end_new_object(&$3, &$4, &$7 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); zend_do_end_variable_parse(&$1, BP_VAR_W, 0 TSRMLS_CC); $3.EA = ZEND_PARSED_NEW; zend_do_assign_ref(&$$, &$1, &$3 TSRMLS_CC); }
| T_CLONE expr { zend_do_clone(&$$, &$2 TSRMLS_CC); }
| variable T_PLUS_EQUAL expr { zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_ADD, &$$, &$1, &$3 TSRMLS_CC); }
| variable T_MINUS_EQUAL expr { zend_check_writable_variable(&$1); zend_do_end_variable_parse(&$1, BP_VAR_RW, 0 TSRMLS_CC); zend_do_binary_assign_op(ZEND_ASSIGN_SUB, &$$, &$1, &$3 TSRMLS_CC); }
@@ -628,6 +771,8 @@
| expr T_IS_GREATER_OR_EQUAL expr { zend_do_binary_op(ZEND_IS_SMALLER_OR_EQUAL, &$$, &$3, &$1 TSRMLS_CC); }
| expr T_INSTANCEOF class_name_reference { zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); }
| '(' expr ')' { $$ = $2; }
+ | new_expr { $$ = $1; }
+ | '(' new_expr ')' { $$ = $2; } instance_call { $$ = $5; }
| expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
expr { zend_do_qm_false(&$$, &$7, &$2, &$5 TSRMLS_CC); }
@@ -645,14 +790,17 @@
| '@' { zend_do_begin_silence(&$1 TSRMLS_CC); } expr { zend_do_end_silence(&$1 TSRMLS_CC); $$ = $3; }
| scalar { $$ = $1; }
| T_ARRAY '(' array_pair_list ')' { $$ = $3; }
+ | '[' array_pair_list ']' { $$ = $2; }
| '`' backticks_expr '`' { zend_do_shell_exec(&$$, &$2 TSRMLS_CC); }
| T_PRINT expr { zend_do_print(&$$, &$2 TSRMLS_CC); }
- | function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type TSRMLS_CC); }
+ | function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$1, $2.op_type, 0 TSRMLS_CC); }
parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$1 TSRMLS_CC); $$ = $4; }
+ | T_STATIC function is_reference '(' { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); }
+ parameter_list ')' lexical_vars '{' inner_statement_list '}' { zend_do_end_function_declaration(&$2 TSRMLS_CC); $$ = $5; }
;
function:
- T_FUNCTION { $$.u.opline_num = CG(zend_lineno); }
+ T_FUNCTION { $$.u.op.opline_num = CG(zend_lineno); }
;
lexical_vars:
@@ -668,22 +816,22 @@
;
function_call:
- namespace_name '(' { $2.u.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); }
+ namespace_name '(' { $2.u.op.opline_num = zend_do_begin_function_call(&$1, 1 TSRMLS_CC); }
function_call_parameter_list
- ')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
- | T_NAMESPACE T_NS_SEPARATOR namespace_name '(' { $1.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$1.u.constant); zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC); $4.u.opline_num = zend_do_begin_function_call(&$1, 0 TSRMLS_CC); }
+ ')' { zend_do_end_function_call(&$1, &$$, &$4, 0, $2.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
+ | T_NAMESPACE T_NS_SEPARATOR namespace_name '(' { $1.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$1.u.constant); zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC); $4.u.op.opline_num = zend_do_begin_function_call(&$1, 0 TSRMLS_CC); }
function_call_parameter_list
- ')' { zend_do_end_function_call(&$1, &$$, &$6, 0, $4.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
- | T_NS_SEPARATOR namespace_name '(' { $3.u.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
+ ')' { zend_do_end_function_call(&$1, &$$, &$6, 0, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
+ | T_NS_SEPARATOR namespace_name '(' { $3.u.op.opline_num = zend_do_begin_function_call(&$2, 0 TSRMLS_CC); }
function_call_parameter_list
- ')' { zend_do_end_function_call(&$2, &$$, &$5, 0, $3.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
- | class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { $4.u.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
+ ')' { zend_do_end_function_call(&$2, &$$, &$5, 0, $3.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
+ | class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { $4.u.op.opline_num = zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
function_call_parameter_list
- ')' { zend_do_end_function_call($4.u.opline_num?NULL:&$3, &$$, &$6, $4.u.opline_num, $4.u.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
+ ')' { zend_do_end_function_call($4.u.op.opline_num?NULL:&$3, &$$, &$6, $4.u.op.opline_num, $4.u.op.opline_num TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
| class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
function_call_parameter_list
')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
- | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
+ | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_name '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
function_call_parameter_list
')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(&$3, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
@@ -692,6 +840,8 @@
| variable_without_objects '(' { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call(&$1, 0 TSRMLS_CC); }
function_call_parameter_list ')'
{ zend_do_end_function_call(&$1, &$$, &$4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
+ | function_call '(' { zend_do_end_variable_parse($1, BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call($1, 0 TSRMLS_CC); }
+ function_call_parameter_list ')'
;
class_name:
@@ -717,8 +867,8 @@
dynamic_class_name_reference:
base_variable T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
- object_property { zend_do_push_object(&$4 TSRMLS_CC); zend_do_declare_implicit_property(TSRMLS_C); } dynamic_class_name_variable_properties
- { zend_do_pop_object(&$$ TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_MEMBER; }
+ object_property { zend_do_push_object(&$4 TSRMLS_CC); } dynamic_class_name_variable_properties
+ { zend_do_pop_object(&$$ TSRMLS_CC); $$.EA = ZEND_PARSED_MEMBER; }
| base_variable { $$ = $1; }
;
@@ -730,7 +880,7 @@
dynamic_class_name_variable_property:
- T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); zend_do_declare_implicit_property(TSRMLS_C); }
+ T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); }
;
exit_expr:
@@ -760,6 +910,7 @@
| T_FILE { $$ = $1; }
| T_DIR { $$ = $1; }
| T_CLASS_C { $$ = $1; }
+ | T_TRAIT_C { $$ = $1; }
| T_METHOD_C { $$ = $1; }
| T_FUNC_C { $$ = $1; }
| T_NS_C { $$ = $1; }
@@ -776,6 +927,7 @@
| '+' static_scalar { ZVAL_LONG(&$1.u.constant, 0); add_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
| '-' static_scalar { ZVAL_LONG(&$1.u.constant, 0); sub_function(&$2.u.constant, &$1.u.constant, &$2.u.constant TSRMLS_CC); $$ = $2; }
| T_ARRAY '(' static_array_pair_list ')' { $$ = $3; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
+ | '[' static_array_pair_list ']' { $$ = $2; Z_TYPE($$.u.constant) = IS_CONSTANT_ARRAY; }
| static_class_constant { $$ = $1; }
;
@@ -836,26 +988,35 @@
variable:
base_variable_with_function_calls T_OBJECT_OPERATOR { zend_do_push_object(&$1 TSRMLS_CC); }
object_property { zend_do_push_object(&$4 TSRMLS_CC); } method_or_not variable_properties
- { zend_do_pop_object(&$$ TSRMLS_CC); $$.u.EA.type = $1.u.EA.type | ($7.u.EA.type ? $7.u.EA.type : $6.u.EA.type); }
+ { zend_do_pop_object(&$$ TSRMLS_CC); $$.EA = $1.EA | ($7.EA ? $7.EA : $6.EA); }
| base_variable_with_function_calls { $$ = $1; }
;
variable_properties:
- variable_properties variable_property { $$.u.EA.type = $2.u.EA.type; }
- | /* empty */ { $$.u.EA.type = 0; }
+ variable_properties variable_property { $$.EA = $2.EA; }
+ | /* empty */ { $$.EA = 0; }
;
variable_property:
- T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); } method_or_not { $$.u.EA.type = $4.u.EA.type; }
+ T_OBJECT_OPERATOR object_property { zend_do_push_object(&$2 TSRMLS_CC); } method_or_not { $$.EA = $4.EA; }
;
-method_or_not:
+array_method_dereference:
+ array_method_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
+ | method '[' dim_offset ']' { $1.EA = ZEND_PARSED_METHOD_CALL; fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
+;
+
+method:
'(' { zend_do_pop_object(&$1 TSRMLS_CC); zend_do_begin_method_call(&$1 TSRMLS_CC); }
function_call_parameter_list ')'
- { zend_do_end_function_call(&$1, &$$, &$3, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);
- zend_do_push_object(&$$ TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_METHOD_CALL; }
- | /* empty */ { zend_do_declare_implicit_property(TSRMLS_C); $$.u.EA.type = ZEND_PARSED_MEMBER; }
+ { zend_do_end_function_call(&$1, &$$, &$3, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); }
+;
+
+method_or_not:
+ method { $$ = $1; $$.EA = ZEND_PARSED_METHOD_CALL; zend_do_push_object(&$$ TSRMLS_CC); }
+ | array_method_dereference { $$ = $1; zend_do_push_object(&$$ TSRMLS_CC); }
+ | /* empty */ { $$.EA = ZEND_PARSED_MEMBER; }
;
variable_without_objects:
@@ -873,16 +1034,23 @@
reference_variable { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); $$=$1;; }
;
+array_function_dereference:
+ array_function_dereference '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$3 TSRMLS_CC); }
+ | function_call { zend_do_begin_variable_parse(TSRMLS_C); $1.EA = ZEND_PARSED_FUNCTION_CALL; }
+ '[' dim_offset ']' { fetch_array_dim(&$$, &$1, &$4 TSRMLS_CC); }
+;
+
base_variable_with_function_calls:
base_variable { $$ = $1; }
- | function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; $$.u.EA.type = ZEND_PARSED_FUNCTION_CALL; }
+ | array_function_dereference { $$ = $1; }
+ | function_call { zend_do_begin_variable_parse(TSRMLS_C); $$ = $1; $$.EA = ZEND_PARSED_FUNCTION_CALL; }
;
base_variable:
- reference_variable { $$ = $1; $$.u.EA.type = ZEND_PARSED_VARIABLE; }
- | simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); $$.u.EA.type = ZEND_PARSED_VARIABLE; }
- | static_member { $$ = $1; $$.u.EA.type = ZEND_PARSED_STATIC_MEMBER; }
+ reference_variable { $$ = $1; $$.EA = ZEND_PARSED_VARIABLE; }
+ | simple_indirect_reference reference_variable { zend_do_indirect_references(&$$, &$1, &$2 TSRMLS_CC); $$.EA = ZEND_PARSED_VARIABLE; }
+ | static_member { $$ = $1; $$.EA = ZEND_PARSED_STATIC_MEMBER; }
;
reference_variable:
@@ -1000,6 +1168,74 @@
;
%%
+
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T zend_yytnamerr(char *yyres, const char *yystr)
+{
+ if (!yyres) {
+ return yystrlen(yystr);
+ }
+ {
+ TSRMLS_FETCH();
+ if (CG(parse_error) == 0) {
+ char buffer[120];
+ const unsigned char *end, *str, *tok1 = NULL, *tok2 = NULL;
+ unsigned int len = 0, toklen = 0, yystr_len;
+
+ CG(parse_error) = 1;
+
+ if (LANG_SCNG(yy_text)[0] == 0 &&
+ LANG_SCNG(yy_leng) == 1 &&
+ memcmp(yystr, ZEND_STRL("\"end of file\"")) == 0) {
+ yystpcpy(yyres, "end of file");
+ return sizeof("end of file")-1;
+ }
+
+ str = LANG_SCNG(yy_text);
+ end = memchr(str, '\n', LANG_SCNG(yy_leng));
+ yystr_len = yystrlen(yystr);
+
+ if ((tok1 = memchr(yystr, '(', yystr_len)) != NULL
+ && (tok2 = zend_memrchr(yystr, ')', yystr_len)) != NULL) {
+ toklen = (tok2 - tok1) + 1;
+ } else {
+ tok1 = tok2 = NULL;
+ toklen = 0;
+ }
+
+ if (end == NULL) {
+ len = LANG_SCNG(yy_leng) > 30 ? 30 : LANG_SCNG(yy_leng);
+ } else {
+ len = (end - str) > 30 ? 30 : (end - str);
+ }
+ if (toklen) {
+ snprintf(buffer, sizeof(buffer), "'%.*s' %.*s", len, str, toklen, tok1);
+ } else {
+ snprintf(buffer, sizeof(buffer), "'%.*s'", len, str);
+ }
+ yystpcpy(yyres, buffer);
+ return len + (toklen ? toklen + 1 : 0) + 2;
+ }
+ }
+ if (*yystr == '"') {
+ YYSIZE_T yyn = 0;
+ const char *yyp = yystr;
+
+ for (; *++yyp != '"'; ++yyn) {
+ yyres[yyn] = *yyp;
+ }
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ yystpcpy(yyres, yystr);
+ return strlen(yystr);
+}
/*
* Local variables:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment