summaryrefslogtreecommitdiff
path: root/ast.c
diff options
context:
space:
mode:
authorktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-17 06:48:03 +0000
committerktsj <ktsj@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-17 06:48:03 +0000
commit9738f96fcfe50b2a605e350bdd40bd7a85665f54 (patch)
treea8495fa0a315ef4015f01db4d158b74987d18277 /ast.c
parentb077654a2c89485c086e77c337d30a11ff3781c3 (diff)
Introduce pattern matching [EXPERIMENTAL]
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ast.c')
-rw-r--r--ast.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ast.c b/ast.c
index 18562f252c..9b57a09198 100644
--- a/ast.c
+++ b/ast.c
@@ -364,8 +364,12 @@ node_children(rb_ast_t *ast, NODE *node)
return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
case NODE_CASE2:
return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ case NODE_CASE3:
+ return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
case NODE_WHEN:
return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
+ case NODE_IN:
+ return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
case NODE_WHILE:
goto loop;
case NODE_UNTIL:
@@ -622,6 +626,22 @@ node_children(rb_ast_t *ast, NODE *node)
}
return rb_ary_new_from_args(3, locals, NEW_CHILD(ast, node->nd_args), NEW_CHILD(ast, node->nd_body));
}
+ case NODE_ARYPTN:
+ {
+ struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
+ return rb_ary_new_from_args(4,
+ NEW_CHILD(ast, node->nd_pconst),
+ NEW_CHILD(ast, apinfo->pre_args),
+ NEW_CHILD(ast, apinfo->rest_arg),
+ NEW_CHILD(ast, apinfo->post_args));
+ }
+ case NODE_HSHPTN:
+ {
+ return rb_ary_new_from_args(3,
+ NEW_CHILD(ast, node->nd_pconst),
+ NEW_CHILD(ast, node->nd_pkwargs),
+ NEW_CHILD(ast, node->nd_pkwrestarg));
+ }
case NODE_ARGS_AUX:
case NODE_LAST:
break;