@@ -86,6 +86,9 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
86
86
%precedence T_ELSEIF
87
87
%precedence T_ELSE
88
88
89
+ %precedence T_DEFAULT
90
+ %precedence T_SWITCH_DEFAULT
91
+
89
92
%token <ast> T_LNUMBER " integer"
90
93
%token <ast> T_DNUMBER " floating-point number"
91
94
%token <ast> T_STRING " identifier"
@@ -251,7 +254,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
251
254
%type <ast> group_use_declaration inline_use_declarations inline_use_declaration
252
255
%type <ast> mixed_group_use_declaration use_declaration unprefixed_use_declaration
253
256
%type <ast> unprefixed_use_declarations const_decl inner_statement
254
- %type <ast> expr expr_with_default optional_expr while_statement for_statement foreach_variable
257
+ %type <ast> expr optional_expr while_statement for_statement foreach_variable
255
258
%type <ast> foreach_statement declare_statement finally_statement unset_variable variable
256
259
%type <ast> extends_from parameter optional_type_without_static argument global_var
257
260
%type <ast> static_var class_statement trait_adaptation trait_precedence trait_alias
@@ -702,9 +705,9 @@ switch_case_list:
702
705
703
706
case_list :
704
707
%empty { $$ = zend_ast_create_list(0 , ZEND_AST_SWITCH_LIST); }
705
- | case_list T_CASE expr case_separator inner_statement_list
708
+ | case_list T_CASE expr case_separator inner_statement_list % prec T_SWITCH_DEFAULT
706
709
{ $$ = zend_ast_list_add($1 , zend_ast_create(ZEND_AST_SWITCH_CASE, $3 , $5 )); }
707
- | case_list T_DEFAULT case_separator inner_statement_list
710
+ | case_list T_DEFAULT case_separator inner_statement_list % prec T_SWITCH_DEFAULT
708
711
{ $$ = zend_ast_list_add($1 , zend_ast_create(ZEND_AST_SWITCH_CASE, NULL , $4 )); }
709
712
;
710
713
@@ -716,7 +719,7 @@ case_separator:
716
719
717
720
match :
718
721
T_MATCH ' (' expr ' )' ' {' match_arm_list ' }'
719
- { $$ = zend_ast_create(ZEND_AST_MATCH, $3 , $6 ); };
722
+ { $$ = zend_ast_create(ZEND_AST_MATCH, $3 , $6 ); }
720
723
;
721
724
722
725
match_arm_list :
@@ -732,8 +735,6 @@ non_empty_match_arm_list:
732
735
match_arm :
733
736
match_arm_cond_list possible_comma T_DOUBLE_ARROW expr
734
737
{ $$ = zend_ast_create(ZEND_AST_MATCH_ARM, $1 , $4 ); }
735
- | T_DEFAULT possible_comma T_DOUBLE_ARROW expr
736
- { $$ = zend_ast_create(ZEND_AST_MATCH_ARM, NULL , $4 ); }
737
738
;
738
739
739
740
match_arm_cond_list :
@@ -904,7 +905,7 @@ non_empty_argument_list:
904
905
;
905
906
906
907
argument :
907
- expr_with_default { $$ = $1 ; }
908
+ expr { $$ = $1 ; }
908
909
| identifier ' :' expr
909
910
{ $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1 , $3 ); }
910
911
| T_ELLIPSIS expr { $$ = zend_ast_create(ZEND_AST_UNPACK, $2 ); }
@@ -1321,16 +1322,12 @@ expr:
1321
1322
| inline_function { $$ = $1 ; }
1322
1323
| attributes inline_function { $$ = zend_ast_with_attributes($2 , $1 ); }
1323
1324
| T_STATIC inline_function { $$ = $2 ; ((zend_ast_decl *) $$ )->flags |= ZEND_ACC_STATIC; }
1325
+ | T_DEFAULT { $$ = zend_ast_create(ZEND_AST_DEFAULT); }
1324
1326
| attributes T_STATIC inline_function
1325
1327
{ $$ = zend_ast_with_attributes($3 , $1 ); ((zend_ast_decl *) $$ )->flags |= ZEND_ACC_STATIC; }
1326
1328
| match { $$ = $1 ; }
1327
1329
;
1328
1330
1329
- expr_with_default :
1330
- expr { $$ = $1 ; }
1331
- | T_DEFAULT { $$ = zend_ast_create(ZEND_AST_DEFAULT); }
1332
- ;
1333
-
1334
1331
inline_function :
1335
1332
function returns_ref backup_doc_comment ' (' parameter_list ' )' lexical_vars return_type
1336
1333
backup_fn_flags ' {' inner_statement_list ' }' backup_fn_flags
0 commit comments