aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-28 21:12:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-28 21:12:05 +0000
commit3380974143d3fdf1721d9e28d6b2d42036f03bd2 (patch)
tree86a60ee982dbdc8f2c68900a43327765b648822e /parse.y
parent82fa2995b5ca47d3383cce82ba5c75da4f09da5a (diff)
downloadruby-3380974143d3fdf1721d9e28d6b2d42036f03bd2.tar.gz
* parse.y (assoc, parser_yylex): add syntax to splat keyword hash.
[ruby-core:44591][Feature #6353] * compile.c (compile_array_): generate keyword splat insns. * vm.c (m_core_hash_merge_kwd): merge keyword hash into intermediate hash. leftward argument is prior currently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y32
1 files changed, 30 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 87d68df46a..1a5e9bc7fa 100644
--- a/parse.y
+++ b/parse.y
@@ -759,6 +759,7 @@ static void token_info_pop(struct parser_params*, const char *token);
%token tLBRACE /* { */
%token tLBRACE_ARG /* { */
%token tSTAR /* * */
+%token tDSTAR /* ** */
%token tAMPER /* & */
%token tLAMBDA /* -> */
%token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG
@@ -805,6 +806,7 @@ static void token_info_pop(struct parser_params*, const char *token);
%nonassoc id_core_hash_from_ary
%nonassoc id_core_hash_merge_ary
%nonassoc id_core_hash_merge_ptr
+%nonassoc id_core_hash_merge_kwd
%token tLAST_TOKEN
@@ -1918,6 +1920,7 @@ op : '|' { ifndef_ripper($$ = '|'); }
| '/' { ifndef_ripper($$ = '/'); }
| '%' { ifndef_ripper($$ = '%'); }
| tPOW { ifndef_ripper($$ = tPOW); }
+ | tDSTAR { ifndef_ripper($$ = tDSTAR); }
| '!' { ifndef_ripper($$ = '!'); }
| '~' { ifndef_ripper($$ = '~'); }
| tUPLUS { ifndef_ripper($$ = tUPLUS); }
@@ -4699,7 +4702,11 @@ f_kwarg : f_kw
}
;
-f_kwrest : tPOW tIDENTIFIER
+kwrest_mark : tPOW
+ | tDSTAR
+ ;
+
+f_kwrest : kwrest_mark tIDENTIFIER
{
$$ = $2;
}
@@ -4923,6 +4930,16 @@ assoc : arg_value tASSOC arg_value
$$ = dispatch2(assoc_new, $1, $2);
%*/
}
+ | tDSTAR arg_value
+ {
+ /*%%%*/
+ $$ = list_append(NEW_LIST(0), $2);
+ /*%
+ $$ = dispatch1(assoc_splat, $2);
+ %*/
+ }
+ ;
+
;
operation : tIDENTIFIER
@@ -6890,7 +6907,17 @@ parser_yylex(struct parser_params *parser)
return tOP_ASGN;
}
pushback(c);
- c = tPOW;
+ if (IS_SPCARG(c)) {
+ rb_warning0("`**' interpreted as argument prefix");
+ c = tDSTAR;
+ }
+ else if (IS_BEG()) {
+ c = tDSTAR;
+ }
+ else {
+ warn_balanced("**", "argument prefix");
+ c = tPOW;
+ }
}
else {
if (c == '=') {
@@ -9701,6 +9728,7 @@ static const struct {
{'+', "+(binary)"},
{'-', "-(binary)"},
{tPOW, "**"},
+ {tDSTAR, "**"},
{tUPLUS, "+@"},
{tUMINUS, "-@"},
{tCMP, "<=>"},