From: "Aleksi Niemelä" Date: 2000-10-11T01:56:29+09:00 Subject: [ruby-talk:5391] Re: Allowing *ary's in the middle of a camma separated list Guy stated, and proposed a grammar change: > I know nothing about ruby, but you just need to change args no ? Well, to begin with, your statement about yourself is a school example of understatement :). And to continue, I think you're right about the parsing change, though as I know nothing about Ruby (see the pattern :), I can't say for sure. Anyway, if that's the way it could go, here's a patch. If you look at it, provided it works, it will simplify the grammar a lot. I can't say either if this is what we really want, but I tried to investigate if semantics for lhs-variants get changed, and found nothing. Anyway, I don't have access to proper development machine right now, so I couldn't compile nor test the code of real parser, nor if it affects lhs or f_args. So no guarantees. Bison didn't report any warning or conflicts. (Few "development" versions did. :) The patch is taken against 1.6.0 source from 2000-09-07. Humm...maybe I should get latest on this machine too... - Aleksi --- ../ruby/ruby/parse.y Mon Sep 11 22:25:36 2000 +++ parse.y Tue Oct 10 18:36:11 2000 @@ -884,20 +884,10 @@ { $$ = $1; } - | args ',' tSTAR arg opt_nl - { - value_expr($4); - $$ = arg_concat($1, $4); - } | assocs trailer { $$ = NEW_LIST(NEW_HASH($1)); } - | tSTAR arg opt_nl - { - value_expr($2); - $$ = NEW_RESTARGS($2); - } opt_call_args : none | call_args opt_nl @@ -922,12 +912,6 @@ { $$ = arg_blk_pass($1, $2); } - | args ',' tSTAR arg opt_block_arg - { - value_expr($4); - $$ = arg_concat($1, $4); - $$ = arg_blk_pass($$, $5); - } | assocs ',' { $$ = NEW_LIST(NEW_HASH($1)); @@ -958,11 +942,6 @@ $$ = arg_concat(list_append($1, NEW_HASH($3)), $6); $$ = arg_blk_pass($$, $7); } - | tSTAR arg opt_block_arg - { - value_expr($2); - $$ = arg_blk_pass(NEW_RESTARGS($2), $3); - } | block_arg block_arg : tAMPER arg @@ -982,11 +961,21 @@ value_expr($1); $$ = NEW_LIST($1); } + | tSTAR arg + { + value_expr($2); + $$ = $2; + } | args ',' arg { value_expr($3); $$ = list_append($1, $3); } + | args ',' tSTAR arg + { + value_expr($4); + $$ = arg_concat($1, $4); + } mrhs : args { @@ -1000,16 +989,6 @@ $$ = $1; } } - | args ',' tSTAR arg - { - value_expr($4); - $$ = arg_concat($1, $4); - } - | tSTAR arg - { - value_expr($2); - $$ = $2; - } ret_args : call_args { @@ -1469,16 +1448,6 @@ } when_args : args - | args ',' tSTAR arg - { - value_expr($4); - $$ = list_append($1, NEW_WHEN($4, 0, 0)); - } - | tSTAR arg - { - value_expr($2); - $$ = NEW_LIST(NEW_WHEN($2, 0, 0)); - } cases : opt_else | case_body