Skip to content

Commit ad16286

Browse files
committed
Parser stuff
1 parent 44db46c commit ad16286

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Zend/zend_language_parser.y

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
4646
%define api.pure full
4747
%define api.value.type {zend_parser_stack_elem}
4848
%define parse.error verbose
49-
%expect 1
49+
%expect 0
5050

5151
%destructor { zend_ast_destroy($$); } <ast>
5252
%destructor { if ($$) zend_string_release_ex($$, 0); } <str>
@@ -285,7 +285,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
285285
%type <ast> enum_declaration_statement enum_backing_type enum_case enum_case_expr
286286
%type <ast> function_name non_empty_member_modifiers
287287
%type <ast> property_hook property_hook_list optional_property_hook_list hooked_property property_hook_body
288-
%type <ast> optional_parameter_list
288+
%type <ast> optional_parameter_list parens_less_argument_list non_empty_parens_less_argument_list
289289

290290
%type <num> returns_ref function fn is_reference is_variadic property_modifiers property_hook_modifiers
291291
%type <num> method_modifiers class_const_modifiers member_modifier optional_cpp_modifiers
@@ -905,6 +905,22 @@ argument_list:
905905
| '(' T_ELLIPSIS ')' { $$ = zend_ast_create_fcc(); }
906906
;
907907

908+
parens_less_argument_list:
909+
'(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); }
910+
| '(' non_empty_parens_less_argument_list possible_comma ')' { $$ = $2; }
911+
| '(' T_ELLIPSIS ')' { $$ = zend_ast_create_fcc(); }
912+
;
913+
914+
non_empty_parens_less_argument_list:
915+
expr ',' argument
916+
{ $$ = zend_ast_list_add(zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1), $3); }
917+
| identifier ':' expr
918+
{ $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, zend_ast_create(ZEND_AST_NAMED_ARG, $1, $3)); }
919+
| T_ELLIPSIS expr { $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, zend_ast_create(ZEND_AST_UNPACK, $2)); }
920+
| non_empty_parens_less_argument_list ',' argument
921+
{ $$ = zend_ast_list_add($1, $3); }
922+
;
923+
908924
non_empty_argument_list:
909925
argument
910926
{ $$ = zend_ast_create_list(1, ZEND_AST_ARG_LIST, $1); }
@@ -1226,7 +1242,7 @@ expr:
12261242
{ $$ = zend_ast_create(ZEND_AST_ASSIGN, $1, $3); }
12271243
| variable '=' ampersand variable
12281244
{ $$ = zend_ast_create(ZEND_AST_ASSIGN_REF, $1, $4); }
1229-
| T_CLONE argument_list {
1245+
| T_CLONE parens_less_argument_list {
12301246
zend_ast *name = zend_ast_create_zval_from_str(ZSTR_KNOWN(ZEND_STR_CLONE));
12311247
name->attr = ZEND_NAME_FQ;
12321248
$$ = zend_ast_create(ZEND_AST_CALL, name, $2);

0 commit comments

Comments
 (0)