summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-05 13:16:40 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-04-05 13:16:40 +0000
commite5af80c69779c10e237a20d1b04daf2453d5dc0c (patch)
tree16cc51ce826699c44ab06858cfa95d431da6e5ca /parse.y
parentd0dec9337b76267676bf8e62cf7cd189e2dff14e (diff)
* parse.y (assoc_list): {a: 1, b: 2} should be allowed. [ruby-dev:23328]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y17
1 files changed, 14 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index 1408622cf5..d4d34216be 100644
--- a/parse.y
+++ b/parse.y
@@ -261,7 +261,7 @@ static void top_local_setup();
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
%type <node> mrhs superclass block_call block_command
%type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg
-%type <node> assoc_list assocs assoc undef_list backref string_dvar
+%type <node> assoc_list assocs assoc kwargs undef_list backref string_dvar
%type <node> block_var opt_block_var brace_block cmd_brace_block do_block lhs none
%type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
%type <id> fitem variable sym symbol operation operation2 operation3
@@ -2381,9 +2381,9 @@ assoc_list : none
}
$$ = $1;
}
- | tLABEL arg_value
+ | kwargs trailer
{
- $$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
+ $$ = $1;
}
;
@@ -2400,6 +2400,17 @@ assoc : arg_value tASSOC arg_value
}
;
+kwargs : tLABEL arg_value
+ {
+ $$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
+ }
+ | kwargs ',' tLABEL arg_value
+ {
+ $$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($3))), $4);
+ $$ = list_concat($1, $$);
+ }
+ ;
+
operation : tIDENTIFIER
| tCONSTANT
| tFID