From 2299294a7d8a0ca77418b7af5c638e714103f905 Mon Sep 17 00:00:00 2001 From: aamine Date: Mon, 5 Apr 2004 13:16:40 +0000 Subject: * parse.y (assoc_list): {a: 1, b: 2} should be allowed. [ruby-dev:23328] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 1408622cf..d4d34216b 100644 --- a/parse.y +++ b/parse.y @@ -261,7 +261,7 @@ static void top_local_setup(); %type command_args aref_args opt_block_arg block_arg var_ref var_lhs %type mrhs superclass block_call block_command %type f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg -%type assoc_list assocs assoc undef_list backref string_dvar +%type assoc_list assocs assoc kwargs undef_list backref string_dvar %type block_var opt_block_var brace_block cmd_brace_block do_block lhs none %type mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node %type 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 -- cgit