|
|
Choosing A Webhost: |
[ruby-dev:28844] Re: when *a: msg#00168lang.ruby.devel
なかだです。 At Sat, 24 Jun 2006 23:53:27 +0900, Yukihiro Matsumoto wrote in [ruby-dev:28829]: > |At Sat, 24 Jun 2006 14:14:15 +0900, > |Minero Aoki wrote in [ruby-dev:28822]: > |> 次のように、when *a が動作しなくなっています。 > | > |こんなとこでしょうか。 > > コミットしてください。 これだと when /b/, *[/a/] のような場合に動作してませんでした。 現状ではargsをそのまま使うようになっていますが、「ひとつひとつ 評価してはマッチさせる」という動作には不向きです。when_argsを復 活させたほうがいいような気がします。 Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.903 diff -p -U2 -r1.903 eval.c --- eval.c 23 Jun 2006 08:28:04 -0000 1.903 +++ eval.c 25 Jun 2006 08:01:46 -0000 @@ -2855,5 +2868,5 @@ rb_eval(VALUE self, NODE *n) ruby_frame->this_func, ruby_frame->this_class); - if (tag->nd_head && nd_type(tag->nd_head) == NODE_WHEN) { + if (tag->nd_head && nd_type(tag->nd_head) == NODE_SPLAT) { VALUE v = rb_eval(self, tag->nd_head->nd_head); long i; Index: parse.y =================================================================== RCS file: /cvs/ruby/src/ruby/parse.y,v retrieving revision 1.443 diff -p -U2 -r1.443 parse.y --- parse.y 21 Jun 2006 08:08:34 -0000 1.443 +++ parse.y 25 Jun 2006 07:56:00 -0000 @@ -533,5 +536,5 @@ static void ripper_compile_error(struct %type <node> expr_value arg_value primary_value %type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure -%type <node> args call_args call_args2 opt_call_args +%type <node> args when_args call_args call_args2 opt_call_args %type <node> open_args paren_args opt_paren_args %type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs @@ -3377,5 +3385,5 @@ brace_block : '{' ; -case_body : kWHEN args then +case_body : kWHEN when_args then compstmt cases @@ -3389,4 +3397,38 @@ case_body : kWHEN args then ; +when_args : arg_value + { + /*%%%*/ + $$ = NEW_LIST($1); + /*% + $$ = arg_add(arg_new(), $1); + %*/ + } + | tSTAR arg_value + { + /*%%%*/ + $$ = NEW_LIST(NEW_SPLAT($2)); + /*% + $$ = arg_add_star(arg_new(), $2); + %*/ + } + | when_args ',' arg_value + { + /*%%%*/ + $$ = list_append($1, $3); + /*% + $$ = arg_add($1, $3); + %*/ + } + | when_args ',' tSTAR arg_value + { + /*%%%*/ + $$ = list_append($1, NEW_SPLAT($4)); + /*% + $$ = arg_add_star($1, $4); + %*/ + } + ; + cases : opt_else | case_body -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [ruby-dev:28843] ripper core dump with arg_paren, Tanaka Akira |
|---|---|
| Next by Date: | [ruby-dev:28845] Re: ruby 1.8.5 preview1 (Re: Re: 1.8.5 release schedule?), とみたまさひろ |
| Previous by Thread: | [ruby-dev:28829] Re: when *a, Yukihiro Matsumoto |
| Next by Thread: | [ruby-dev:28871] Re: when *a, Yukihiro Matsumoto |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |