]> granicus.if.org Git - php/commitdiff
Improved parser (make use_type reuseable)
authorXinchen Hui <laruence@php.net>
Mon, 16 Mar 2015 10:43:21 +0000 (18:43 +0800)
committerXinchen Hui <laruence@php.net>
Mon, 16 Mar 2015 10:43:36 +0000 (18:43 +0800)
Zend/zend_language_parser.y

index 69544ecf04d489282afbb5b84419d7c42851f150..61ae8c5614996cf47f93ede690cd32d87bec66c3 100644 (file)
@@ -299,17 +299,14 @@ top_statement:
                '{' top_statement_list '}'
                        { $$ = zend_ast_create(ZEND_AST_NAMESPACE, NULL, $4); }
        |       T_USE mixed_group_use_declaration ';'           { $$ = $2; }
-       |       T_USE T_FUNCTION group_use_declaration ';'      { $$ = $3; $$->attr = T_FUNCTION; }
-       |       T_USE T_CONST group_use_declaration ';'         { $$ = $3; $$->attr = T_CONST; }
+       |       T_USE use_type group_use_declaration ';'        { $$ = $3; $$->attr = $2; }
        |       T_USE use_declarations ';'                                      { $$ = $2; $$->attr = T_CLASS; }
-       |       T_USE T_FUNCTION use_declarations ';'           { $$ = $3; $$->attr = T_FUNCTION; }
-       |       T_USE T_CONST use_declarations ';'                      { $$ = $3; $$->attr = T_CONST; }
+       |       T_USE use_type use_declarations ';'                     { $$ = $3; $$->attr = $2; }
        |       T_CONST const_list ';'                                          { $$ = $2; }
 ;
 
 use_type:
-               /* empty */             { $$ = T_CLASS; }
-       |       T_FUNCTION              { $$ = T_FUNCTION; }
+               T_FUNCTION              { $$ = T_FUNCTION; }
        |       T_CONST                 { $$ = T_CONST; }
 ;
 
@@ -331,7 +328,8 @@ inline_use_declarations:
 ;
 
 inline_use_declaration:
-       use_type use_declaration { $$ = $2; $$->attr = $1; }
+               use_declaration { $$ = $1; $$->attr = T_CLASS; }
+       |       use_type use_declaration { $$ = $2; $$->attr = $1; }
 ;
 
 use_declarations: