summaryrefslogtreecommitdiff
path: root/Zend/zend_language_parser.y
diff options
context:
space:
mode:
authorkrakjoe <joe.watkins@live.co.uk>2015-04-26 15:02:57 +0200
committerNikita Popov <nikic@php.net>2015-04-26 15:04:22 +0200
commit49608e0608857638fdc978333764cf52ba270913 (patch)
tree1897a7c45de79780b15dbc547f5f1e4d1436f435 /Zend/zend_language_parser.y
parent1a4d3e4855619538eb1902b8513473e2cda76804 (diff)
downloadphp-git-49608e0608857638fdc978333764cf52ba270913.tar.gz
Rebase Joe's anon classes implementation
Diffstat (limited to 'Zend/zend_language_parser.y')
-rw-r--r--Zend/zend_language_parser.y16
1 files changed, 15 insertions, 1 deletions
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 0aba081218..b197bde991 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -241,7 +241,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%type <ast> extends_from parameter optional_type argument expr_without_variable global_var
%type <ast> static_var class_statement trait_adaptation trait_precedence trait_alias
%type <ast> absolute_trait_method_reference trait_method_reference property echo_expr
-%type <ast> new_expr class_name class_name_reference simple_variable internal_functions_in_yacc
+%type <ast> new_expr anonymous_class class_name class_name_reference simple_variable internal_functions_in_yacc
%type <ast> exit_expr scalar backticks_expr lexical_var function_call member_name
%type <ast> variable_class_name dereferencable_scalar class_name_scalar constant dereferencable
%type <ast> callable_expr callable_variable static_member new_variable
@@ -798,9 +798,23 @@ non_empty_for_exprs:
| expr { $$ = zend_ast_create_list(1, ZEND_AST_EXPR_LIST, $1); }
;
+anonymous_class:
+ T_CLASS ctor_arguments {
+ $<num>$ = CG(zend_lineno);
+ } extends_from implements_list backup_doc_comment '{' class_statement_list '}' {
+ zend_ast *decl = zend_ast_create_decl(
+ ZEND_AST_CLASS,
+ ZEND_ACC_ANON_CLASS,
+ $<num>3, $6, $4, $4, $5, $8, NULL);
+ $$ = zend_ast_create(ZEND_AST_NEW, decl, $2);
+ }
+;
+
new_expr:
T_NEW class_name_reference ctor_arguments
{ $$ = zend_ast_create(ZEND_AST_NEW, $2, $3); }
+ | T_NEW anonymous_class
+ { $$ = $2; }
;
expr_without_variable: