summaryrefslogtreecommitdiff
path: root/Zend/zend_ast.c
diff options
context:
space:
mode:
authorIlija Tovilo <ilija.tovilo@me.com>2020-04-09 22:36:37 +0200
committerIlija Tovilo <ilija.tovilo@me.com>2020-07-09 23:52:17 +0200
commit9fa1d1330138ac424f990ff03e62721120aaaec3 (patch)
treeca3550c82b86ccf844745fbe80c77134ed5cbef4 /Zend/zend_ast.c
parentc60d0dc2f41f1d4817414e37a39ae87c5677e31a (diff)
downloadphp-git-9fa1d1330138ac424f990ff03e62721120aaaec3.tar.gz
Implement match expression
RFC: https://wiki.php.net/rfc/match_expression_v2 Closes GH-5371.
Diffstat (limited to 'Zend/zend_ast.c')
-rw-r--r--Zend/zend_ast.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index 5ffaabfc68..b1e564b5e9 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -1590,6 +1590,7 @@ simple_list:
break;
case ZEND_AST_SWITCH_LIST:
case ZEND_AST_CATCH_LIST:
+ case ZEND_AST_MATCH_ARM_LIST:
zend_ast_export_list(str, (zend_ast_list*)ast, 0, 0, indent);
break;
case ZEND_AST_CLOSURE_USES:
@@ -1967,6 +1968,25 @@ simple_list:
}
zend_ast_export_stmt(str, ast->child[1], indent + 1);
break;
+ case ZEND_AST_MATCH:
+ smart_str_appends(str, "match (");
+ zend_ast_export_ex(str, ast->child[0], 0, indent);
+ smart_str_appends(str, ") {\n");
+ zend_ast_export_ex(str, ast->child[1], 0, indent + 1);
+ zend_ast_export_indent(str, indent);
+ smart_str_appendc(str, '}');
+ break;
+ case ZEND_AST_MATCH_ARM:
+ zend_ast_export_indent(str, indent);
+ if (ast->child[0]) {
+ zend_ast_export_list(str, (zend_ast_list*)ast->child[0], 1, 0, indent);
+ smart_str_appends(str, " => ");
+ } else {
+ smart_str_appends(str, "default => ");
+ }
+ zend_ast_export_ex(str, ast->child[1], 0, 0);
+ smart_str_appends(str, ",\n");
+ break;
case ZEND_AST_DECLARE:
smart_str_appends(str, "declare(");
ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_CONST_DECL);