mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y (args, mrhs): flattens literal array splats.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a10ded3ba0
commit
126297de15
2 changed files with 61 additions and 22 deletions
|
@ -1,3 +1,7 @@
|
|||
Tue Feb 12 16:18:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (args, mrhs): flattens literal array splats.
|
||||
|
||||
Tue Feb 12 15:27:19 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* bootstraptest/runner.rb, bootstraptest/test_method.rb, enc/depend,
|
||||
|
@ -126,7 +130,7 @@ Sun Feb 10 21:58:32 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
|||
Sun Feb 10 16:58:20 2008 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rubygems*, test/rubygems*, gem_prelude.rb: Import RubyGems
|
||||
* r1601. [ruby-core:15381]
|
||||
r1601. [ruby-core:15381]
|
||||
|
||||
Sun Feb 10 15:07:23 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
|
|
35
parse.y
35
parse.y
|
@ -369,6 +369,7 @@ static NODE *new_evstr_gen(struct parser_params*,NODE*);
|
|||
#define new_evstr(n) new_evstr_gen(parser,n)
|
||||
static NODE *evstr2dstr_gen(struct parser_params*,NODE*);
|
||||
#define evstr2dstr(n) evstr2dstr_gen(parser,n)
|
||||
static NODE *splat_array(NODE*);
|
||||
|
||||
static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*);
|
||||
#define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, recv,id,arg1)
|
||||
|
@ -2445,7 +2446,13 @@ args : arg_value
|
|||
| args ',' arg_value
|
||||
{
|
||||
/*%%%*/
|
||||
NODE *n1;
|
||||
if ((n1 = splat_array($1)) != 0) {
|
||||
$$ = list_append(n1, $3);
|
||||
}
|
||||
else {
|
||||
$$ = arg_append($1, $3);
|
||||
}
|
||||
/*%
|
||||
$$ = arg_add($1, $3);
|
||||
%*/
|
||||
|
@ -2453,7 +2460,14 @@ args : arg_value
|
|||
| args ',' tSTAR arg_value
|
||||
{
|
||||
/*%%%*/
|
||||
NODE *n1;
|
||||
if (nd_type($4) == NODE_ARRAY &&
|
||||
(n1 = splat_array($1)) != 0) {
|
||||
$$ = list_concat(n1, $4);
|
||||
}
|
||||
else {
|
||||
$$ = arg_concat($1, $4);
|
||||
}
|
||||
/*%
|
||||
$$ = arg_add_star($1, $4);
|
||||
%*/
|
||||
|
@ -2463,7 +2477,13 @@ args : arg_value
|
|||
mrhs : args ',' arg_value
|
||||
{
|
||||
/*%%%*/
|
||||
NODE *n1;
|
||||
if ((n1 = splat_array($1)) != 0) {
|
||||
$$ = list_append(n1, $3);
|
||||
}
|
||||
else {
|
||||
$$ = arg_append($1, $3);
|
||||
}
|
||||
/*%
|
||||
$$ = mrhs_add(args2mrhs($1), $3);
|
||||
%*/
|
||||
|
@ -2471,7 +2491,14 @@ mrhs : args ',' arg_value
|
|||
| args ',' tSTAR arg_value
|
||||
{
|
||||
/*%%%*/
|
||||
NODE *n1;
|
||||
if (nd_type($4) == NODE_ARRAY &&
|
||||
(n1 = splat_array($1)) != 0) {
|
||||
$$ = list_concat(n1, $4);
|
||||
}
|
||||
else {
|
||||
$$ = arg_concat($1, $4);
|
||||
}
|
||||
/*%
|
||||
$$ = mrhs_add_star(args2mrhs($1), $4);
|
||||
%*/
|
||||
|
@ -7798,6 +7825,14 @@ arg_add_gen(struct parser_params *parser, NODE *node1, NODE *node2)
|
|||
}
|
||||
}
|
||||
|
||||
static NODE *
|
||||
splat_array(NODE* node)
|
||||
{
|
||||
if (nd_type(node) == NODE_SPLAT) node = node->nd_head;
|
||||
if (nd_type(node) == NODE_ARRAY) return node;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NODE *
|
||||
node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue