From 275e7276c1d0523d32802008bb03189996028c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Almada?= Date: Mon, 19 Jan 2015 02:22:23 -0300 Subject: first implementation of batch use compilation --- Zend/zend_language_parser.y | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Zend/zend_language_parser.y') diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index a9794f6fac..1bded228ab 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -229,6 +229,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %type top_statement namespace_name name statement function_declaration_statement %type class_declaration_statement trait_declaration_statement %type interface_declaration_statement interface_extends_list +%type batch_use_declarations inline_use_declarations inline_use_declaration %type use_declaration const_decl inner_statement %type expr optional_expr while_statement for_statement foreach_variable %type foreach_statement declare_statement finally_statement unset_variable variable @@ -297,12 +298,34 @@ top_statement: | T_NAMESPACE { RESET_DOC_COMMENT(); } '{' top_statement_list '}' { $$ = zend_ast_create(ZEND_AST_NAMESPACE, NULL, $4); } + | T_USE batch_use_declarations ';' { $$ = $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_CONST const_list ';' { $$ = $2; } ; +batch_use_declarations: + namespace_name '{' inline_use_declarations '}' + {$$ = zend_ast_create(ZEND_AST_BATCH_USE, $1, $3);} +; + +inline_use_declarations: + inline_use_declarations ',' inline_use_declaration + { $$ = zend_ast_list_add($1, $3); } + | inline_use_declaration + { $$ = zend_ast_create_list(1, ZEND_AST_USE, $1); } +; + +inline_use_declaration: + use_declaration + { $$ = $1; $$->attr = T_CLASS; } + | T_FUNCTION use_declaration + { $$ = $2; $$->attr = T_FUNCTION; } + | T_CONST use_declaration + { $$ = $2; $$->attr = T_CONST; } +; + use_declarations: use_declarations ',' use_declaration { $$ = zend_ast_list_add($1, $3); } -- cgit v1.2.1