Shared name production for const / fn name

This commit is contained in:
Nikita Popov 2014-07-04 23:08:05 +02:00
parent fb98dd31a0
commit fdc318849a

View File

@ -234,6 +234,17 @@ namespace_name:
| namespace_name T_NS_SEPARATOR T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
;
name:
namespace_name
{ $$.u.ast = zend_ast_create_zval_ex(&$1.u.constant, 1); }
| T_NAMESPACE T_NS_SEPARATOR namespace_name
{ ZVAL_EMPTY_STRING(&$1.u.constant);
zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC);
$$.u.ast = AST_ZVAL(&$1); }
| T_NS_SEPARATOR namespace_name
{ $$.u.ast = AST_ZVAL(&$2); }
;
top_statement:
statement { zend_verify_namespace(TSRMLS_C); }
| function_declaration_statement { zend_verify_namespace(TSRMLS_C); zend_do_early_binding(TSRMLS_C); }
@ -890,15 +901,8 @@ lexical_var_list:
;
function_call:
namespace_name function_call_parameter_list
{ $$.u.ast = zend_ast_create_binary(ZEND_AST_CALL,
zend_ast_create_zval_ex(&$1.u.constant, 1), $2.u.ast); }
| T_NAMESPACE T_NS_SEPARATOR namespace_name function_call_parameter_list
{ ZVAL_EMPTY_STRING(&$1.u.constant);
zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC);
$$.u.ast = zend_ast_create_binary(ZEND_AST_CALL, AST_ZVAL(&$1), $4.u.ast); }
| T_NS_SEPARATOR namespace_name function_call_parameter_list
{ $$.u.ast = zend_ast_create_binary(ZEND_AST_CALL, AST_ZVAL(&$2), $3.u.ast); }
name function_call_parameter_list
{ $$.u.ast = zend_ast_create_binary(ZEND_AST_CALL, $1.u.ast, $2.u.ast); }
| class_name T_PAAMAYIM_NEKUDOTAYIM member_name function_call_parameter_list
{ $$.u.ast = zend_ast_create_ternary(ZEND_AST_STATIC_CALL,
AST_ZVAL(&$1), $3.u.ast, $4.u.ast); }
@ -916,21 +920,6 @@ class_name:
| T_NS_SEPARATOR namespace_name { zval tmp; ZVAL_NEW_STR(&tmp, STR_ALLOC(Z_STRLEN($2.u.constant)+1, 0)); Z_STRVAL(tmp)[0] = '\\'; memcpy(Z_STRVAL(tmp) + 1, Z_STRVAL($2.u.constant), Z_STRLEN($2.u.constant)+1); if (Z_DELREF($2.u.constant) == 0) {efree(Z_STR($2.u.constant));} Z_STR($2.u.constant) = Z_STR(tmp); $$ = $2; }
;
/*
class_name:
T_STATIC
{ ZVAL_STRING(&$1.u.constant, "static");
$$.u.ast = AST_ZVAL(&$1); }
| namespace_name { $$.u.ast = zend_ast_create_zval_ex(&$1.u.constant, 1); }
| T_NAMESPACE T_NS_SEPARATOR namespace_name
{ ZVAL_EMPTY_STRING(&$1.u.constant);
zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC);
$$.u.ast = AST_ZVAL(&$1); }
| T_NS_SEPARATOR namespace_name
{ $$.u.ast = AST_ZVAL(&$2); }
;
*/
fully_qualified_class_name:
namespace_name { $$ = $1; }
| T_NAMESPACE T_NS_SEPARATOR namespace_name { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); zend_do_build_namespace_name(&$$, &$$, &$3 TSRMLS_CC); }
@ -1002,15 +991,7 @@ scalar:
| dereferencable_scalar { $$.u.ast = $1.u.ast; }
| class_name_scalar { $$.u.ast = $1.u.ast; }
| class_constant { $$.u.ast = $1.u.ast; }
| namespace_name
{ $$.u.ast = zend_ast_create_unary(
ZEND_AST_CONST, zend_ast_create_zval_ex(&$1.u.constant, 1)); }
| T_NAMESPACE T_NS_SEPARATOR namespace_name
{ ZVAL_EMPTY_STRING(&$1.u.constant);
zend_do_build_namespace_name(&$1, &$1, &$3 TSRMLS_CC);
$$.u.ast = zend_ast_create_unary(ZEND_AST_CONST, AST_ZVAL(&$1)); }
| T_NS_SEPARATOR namespace_name
{ $$.u.ast = zend_ast_create_unary(ZEND_AST_CONST, AST_ZVAL(&$2)); }
| name { $$.u.ast = zend_ast_create_unary(ZEND_AST_CONST, $1.u.ast); }
;