-
-
Save bwoebi/35b30a38874304597ee153544c968958 to your computer and use it in GitHub Desktop.
Deref of more scalars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y | |
index 957d657..1b380fc 100644 | |
--- a/Zend/zend_language_parser.y | |
+++ b/Zend/zend_language_parser.y | |
@@ -240,7 +240,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); | |
%type <ast> internal_functions_in_yacc | |
%type <ast> exit_expr scalar backticks_expr lexical_var function_call member_name property_name | |
%type <ast> variable_class_name dereferencable_scalar constant dereferencable | |
-%type <ast> callable_expr callable_variable static_member new_variable | |
+%type <ast> callable_scalar callable_expr callable_variable static_member new_variable | |
%type <ast> encaps_var encaps_var_offset isset_variables | |
%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 | |
@@ -1059,30 +1059,26 @@ ctor_arguments: | |
; | |
-dereferencable_scalar: | |
+callable_scalar: /* arrays + strings */ | |
T_ARRAY '(' array_pair_list ')' { $$ = $3; $$->attr = ZEND_ARRAY_SYNTAX_LONG; } | |
| '[' array_pair_list ']' { $$ = $2; $$->attr = ZEND_ARRAY_SYNTAX_SHORT; } | |
| T_CONSTANT_ENCAPSED_STRING { $$ = $1; } | |
-; | |
- | |
-scalar: | |
- T_LNUMBER { $$ = $1; } | |
- | T_DNUMBER { $$ = $1; } | |
- | 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); } | |
- | 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; } | |
| T_START_HEREDOC T_END_HEREDOC | |
{ $$ = zend_ast_create_zval_from_str(ZSTR_EMPTY_ALLOC()); } | |
| '"' encaps_list '"' { $$ = $2; } | |
| T_START_HEREDOC encaps_list T_END_HEREDOC { $$ = $2; } | |
+; | |
+ | |
+dereferencable_scalar: | |
+ callable_scalar { $$ = $1; } | |
+ | constant { $$ = $1; } | |
+; | |
+ | |
+scalar: | |
+ T_LNUMBER { $$ = $1; } | |
+ | T_DNUMBER { $$ = $1; } | |
| dereferencable_scalar { $$ = $1; } | |
- | constant { $$ = $1; } | |
; | |
constant: | |
@@ -1091,6 +1087,14 @@ constant: | |
{ $$ = zend_ast_create(ZEND_AST_CLASS_CONST, $1, $3); } | |
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier | |
{ $$ = zend_ast_create(ZEND_AST_CLASS_CONST, $1, $3); } | |
+ | 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); } | |
+ | 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); } | |
; | |
expr: | |
@@ -1104,7 +1108,9 @@ optional_expr: | |
; | |
variable_class_name: | |
- dereferencable { $$ = $1; } | |
+ variable { $$ = $1; } | |
+ | '(' expr ')' { $$ = $2; } | |
+ | callable_scalar { $$ = $1; } | |
; | |
dereferencable: | |
@@ -1116,7 +1122,7 @@ dereferencable: | |
callable_expr: | |
callable_variable { $$ = $1; } | |
| '(' expr ')' { $$ = $2; } | |
- | dereferencable_scalar { $$ = $1; } | |
+ | callable_scalar { $$ = $1; } | |
; | |
callable_variable: | |
@@ -1124,8 +1130,6 @@ callable_variable: | |
{ $$ = zend_ast_create(ZEND_AST_VAR, $1); } | |
| dereferencable '[' optional_expr ']' | |
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); } | |
- | constant '[' optional_expr ']' | |
- { $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); } | |
| dereferencable '{' expr '}' | |
{ $$ = zend_ast_create(ZEND_AST_DIM, $1, $3); } | |
| dereferencable T_OBJECT_OPERATOR property_name argument_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment