[前][次][番号順一覧][スレッド一覧]

ruby-changes:14183

From: yugui <ko1@a...>
Date: Sat, 5 Dec 2009 11:37:19 +0900 (JST)
Subject: [ruby-changes:14183] Ruby:r26002 (ruby_1_9_1): merges r25193 from trunk into ruby_1_9_1.

yugui	2009-12-05 11:36:50 +0900 (Sat, 05 Dec 2009)

  New Revision: 26002

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26002

  Log:
    merges r25193 from trunk into ruby_1_9_1.
    --
    * test/ripper/dummyparser.rb (DummyParser): improvement by Magnus
      Holm in [ruby-core:25884].
      * remove scanner events which simply returned the first argument.
      * all parser events are now automatically generated.
      * simplify blocks.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/test/ripper/dummyparser.rb
    branches/ruby_1_9_1/test/ripper/test_parser_events.rb
    branches/ruby_1_9_1/version.h

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 26001)
+++ ruby_1_9_1/ChangeLog	(revision 26002)
@@ -1,3 +1,11 @@
+Sat Oct  3 00:47:52 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* test/ripper/dummyparser.rb (DummyParser): improvement by Magnus
+	  Holm in [ruby-core:25884].
+	  * remove scanner events which simply returned the first argument.
+	  * all parser events are now automatically generated.
+	  * simplify blocks.
+
 Fri Oct  2 20:37:37 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (ripper_yylval_id, ripper_get_{id,value}): wrap ID by
Index: ruby_1_9_1/version.h
===================================================================
--- ruby_1_9_1/version.h	(revision 26001)
+++ ruby_1_9_1/version.h	(revision 26002)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.1"
-#define RUBY_PATCHLEVEL 358
+#define RUBY_PATCHLEVEL 359
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1
Index: ruby_1_9_1/test/ripper/test_parser_events.rb
===================================================================
--- ruby_1_9_1/test/ripper/test_parser_events.rb	(revision 26001)
+++ ruby_1_9_1/test/ripper/test_parser_events.rb	(revision 26002)
@@ -558,13 +558,13 @@
   def test_local_variables
     cmd = 'command(w,[regexp_literal(xstring_add(xstring_new(),25 # ),/)])'
     div = 'binary(ref(w),/,25)'
-    var = 'params(["w"])'
+    var = '[w]'
     bug1939 = '[ruby-core:24923]'
 
     assert_equal("[#{cmd}]", parse('w /25 # /'), bug1939)
     assert_equal("[assign(var_field(w),1),#{div}]", parse("w = 1; w /25 # /"), bug1939)
-    assert_equal("[fcall(p,[],&brace_block(block_var(#{var}),[#{div}]))]", parse("p{|w|w /25 # /\n}"), bug1939)
-    assert_equal("[def(p,paren(#{var}),bodystmt([#{div}]))]", parse("def p(w)\nw /25 # /\nend"), bug1939)
+    assert_equal("[fcall(p,[],&block([w],[#{div}]))]", parse("p{|w|w /25 # /\n}"), bug1939)
+    assert_equal("[def(p,[w],bodystmt([#{div}]))]", parse("def p(w)\nw /25 # /\nend"), bug1939)
   end
 end
 
Index: ruby_1_9_1/test/ripper/dummyparser.rb
===================================================================
--- ruby_1_9_1/test/ripper/dummyparser.rb	(revision 26001)
+++ ruby_1_9_1/test/ripper/dummyparser.rb	(revision 26002)
@@ -47,6 +47,13 @@
 end
 
 class DummyParser < Ripper
+  Ripper::PARSER_EVENTS.each do |event|
+    event = event.to_s
+    define_method(:"on_#{event}") do |*args|
+      Node.new(event, *args)
+    end
+  end
+
   def hook(name)
     class << self; self; end.class_eval do
       define_method(name) do |*a, &b|
@@ -75,22 +82,10 @@
     Node.new('void')
   end
 
-  def on_BEGIN(stmts)
-    Node.new('BEGIN', stmts)
-  end
-
-  def on_END(stmts)
-    Node.new('END', stmts)
-  end
-
   def on_var_ref(name)
     Node.new('ref', name)
   end
 
-  def on_alias(a, b)
-    Node.new('alias', a, b)
-  end
-
   def on_var_alias(a, b)
     Node.new('valias', a, b)
   end
@@ -99,18 +94,6 @@
     Node.new('aliaserr', a)
   end
 
-  def on_aref(a, b)
-    Node.new('aref', a, b)
-  end
-
-  def on_aref_field(a, b)
-    Node.new('aref_field', a, b)
-  end
-
-  def on_arg_ambiguous
-    Node.new('arg_ambiguous')
-  end
-
   def on_arg_paren(args)
     args
   end
@@ -152,6 +135,47 @@
     on_args_add_block(m.children, b)
     m
   end
+  
+  def on_paren(params)
+    params
+  end
+  
+  def on_brace_block(params, code)
+    Node.new('block', params, code)
+  end
+  
+  def on_block_var(params, shadow)
+    params
+  end
+  
+  def on_rest_param(var)
+    "*#{var}"
+  end
+  
+  def on_blockarg(var)
+    "&#{var}"
+  end
+  
+  def on_params(required, optional, rest, more, block)
+    args = NodeList.new
+    
+    required.each do |req|
+      args.push(req)
+    end if required
+    
+    optional.each do |var, val|
+      args.push("#{var}=#{val}")
+    end if optional
+    
+    args.push(rest) if rest
+    
+    more.each do |m|
+      args.push(m)
+    end if more
+    
+    args.push(block) if block
+    args
+  end
 
   def on_assoc_new(a, b)
     Node.new('assoc', a, b)
@@ -164,425 +188,4 @@
   def on_assoclist_from_args(a)
     Node.new('assocs', *a.list)
   end
-
-  ######## untested
-
-  def on_array(a)
-    Node.new('array', a)
-  end
-
-  def on_assign(a, b)
-    Node.new('assign', a, b)
-  end
-
-  def on_assign_error(a)
-    Node.new('assign_error', a)
-  end
-
-  def on_begin(a)
-    Node.new('begin', a)
-  end
-
-  def on_binary(a, b, c)
-    Node.new('binary', a, b, c)
-  end
-
-  def on_block_var(a, b)
-    Node.new('block_var', a, b)
-  end
-
-  def on_bodystmt(a, b, c, d)
-    Node.new('bodystmt', a, b, c, d)
-  end
-
-  def on_brace_block(a, b)
-    Node.new('brace_block', a, b)
-  end
-
-  def on_break(a)
-    Node.new('break', a)
-  end
-
-  def on_call(a, b, c)
-    Node.new('call', a, b, c)
-  end
-
-  def on_case(a, b)
-    Node.new('case', a, b)
-  end
-
-  def on_class(a, b, c)
-    Node.new('class', a, b, c)
-  end
-
-  def on_class_name_error(a)
-    Node.new('class_name_error', a)
-  end
-
-  def on_command(a, b)
-    Node.new('command', a, b)
-  end
-
-  def on_command_call(a, b, c, d)
-    Node.new('command_call', a, b, c, d)
-  end
-
-  def on_const_ref(a)
-    Node.new('const_ref', a)
-  end
-
-  def on_constpath_field(a, b)
-    Node.new('constpath_field', a, b)
-  end
-
-  def on_constpath_ref(a, b)
-    Node.new('constpath_ref', a, b)
-  end
-
-  def on_def(a, b, c)
-    Node.new('def', a, b, c)
-  end
-
-  def on_defined(a)
-    Node.new('defined', a)
-  end
-
-  def on_defs(a, b, c, d, e)
-    Node.new('defs', a, b, c, d, e)
-  end
-
-  def on_do_block(a, b)
-    Node.new('do_block', a, b)
-  end
-
-  def on_dot2(a, b)
-    Node.new('dot2', a, b)
-  end
-
-  def on_dot3(a, b)
-    Node.new('dot3', a, b)
-  end
-
-  def on_dyna_symbol(a)
-    Node.new('dyna_symbol', a)
-  end
-
-  def on_else(a)
-    Node.new('else', a)
-  end
-
-  def on_elsif(a, b, c)
-    Node.new('elsif', a, b, c)
-  end
-
-  def on_ensure(a)
-    Node.new('ensure', a)
-  end
-
-  def on_fcall(a)
-    Node.new('fcall', a)
-  end
-
-  def on_field(a, b, c)
-    Node.new('field', a, b, c)
-  end
-
-  def on_for(a, b, c)
-    Node.new('for', a, b, c)
-  end
-
-  def on_hash(a)
-    Node.new('hash', a)
-  end
-
-  def on_if(a, b, c)
-    Node.new('if', a, b, c)
-  end
-
-  def on_if_mod(a, b)
-    Node.new('if_mod', a, b)
-  end
-
-  def on_ifop(a, b, c)
-    Node.new('ifop', a, b, c)
-  end
-
-  def on_iter_block(a, b)
-    Node.new('iter_block', a, b)
-  end
-
-  def on_massign(a, b)
-    Node.new('massign', a, b)
-  end
-
-  def on_mlhs_add(a, b)
-    Node.new('mlhs_add', a, b)
-  end
-
-  def on_mlhs_add_star(a, b)
-    Node.new('mlhs_add_star', a, b)
-  end
-
-  def on_mlhs_new
-    Node.new('mlhs_new')
-  end
-
-  def on_mlhs_paren(a)
-    Node.new('mlhs_paren', a)
-  end
-
-  def on_module(a, b)
-    Node.new('module', a, b)
-  end
-
-  def on_mrhs_add(a, b)
-    Node.new('mrhs_add', a, b)
-  end
-
-  def on_mrhs_add_star(a, b)
-    Node.new('mrhs_add_star', a, b)
-  end
-
-  def on_mrhs_new
-    Node.new('mrhs_new')
-  end
-
-  def on_mrhs_new_from_arglist(a)
-    Node.new('mrhs_new_from_arglist', a)
-  end
-
-  def on_next(a)
-    Node.new('next', a)
-  end
-
-  def on_opassign(a, b, c)
-    Node.new('opassign', a, b, c)
-  end
-
-  def on_param_error(a)
-    Node.new('param_error', a)
-  end
-
-  def on_params(a, b, c, d, e)
-    Node.new('params', a, b, c, d, e)
-  end
-
-  def on_paren(a)
-    Node.new('paren', a)
-  end
-
-  def on_parse_error(a)
-    Node.new('parse_error', a)
-  end
-
-  def on_qwords_add(a, b)
-    Node.new('qwords_add', a, b)
-  end
-
-  def on_qwords_new
-    Node.new('qwords_new')
-  end
-
-  def on_redo
-    Node.new('redo')
-  end
-
-  def on_regexp_literal(a, b)
-    Node.new('regexp_literal', a, b)
-  end
-
-  def on_rescue(a, b, c, d)
-    Node.new('rescue', a, b, c, d)
-  end
-
-  def on_rescue_mod(a, b)
-    Node.new('rescue_mod', a, b)
-  end
-
-  def on_restparam(a)
-    Node.new('restparam', a)
-  end
-
-  def on_retry
-    Node.new('retry')
-  end
-
-  def on_return(a)
-    Node.new('return', a)
-  end
-
-  def on_return0
-    Node.new('return0')
-  end
-
-  def on_sclass(a, b)
-    Node.new('sclass', a, b)
-  end
-
-  def on_sp(a)
-    Node.new('space', a)
-  end
-
-  def on_string_add(a, b)
-    Node.new('string_add', a, b)
-  end
-
-  def on_string_concat(a, b)
-    Node.new('string_concat', a, b)
-  end
-
-  def on_string_content
-    Node.new('string_content')
-  end
-
-  def on_string_dvar(a)
-    Node.new('string_dvar', a)
-  end
-
-  def on_string_embexpr(a)
-    Node.new('string_embexpr', a)
-  end
-
-  def on_string_literal(a)
-    Node.new('string_literal', a)
-  end
-
-  def on_super(a)
-    Node.new('super', a)
-  end
-
-  def on_symbol(a)
-    Node.new('symbol', a)
-  end
-
-  def on_symbol_literal(a)
-    Node.new('symbol_literal', a)
-  end
-
-  def on_topconst_field(a)
-    Node.new('topconst_field', a)
-  end
-
-  def on_topconst_ref(a)
-    Node.new('topconst_ref', a)
-  end
-
-  def on_unary(a, b)
-    Node.new('unary', a, b)
-  end
-
-  def on_undef(a)
-    Node.new('undef', a)
-  end
-
-  def on_unless(a, b, c)
-    Node.new('unless', a, b, c)
-  end
-
-  def on_unless_mod(a, b)
-    Node.new('unless_mod', a, b)
-  end
-
-  def on_until_mod(a, b)
-    Node.new('until_mod', a, b)
-  end
-
-  def on_var_field(a)
-    Node.new('var_field', a)
-  end
-
-  def on_when(a, b, c)
-    Node.new('when', a, b, c)
-  end
-
-  def on_while(a, b)
-    Node.new('while', a, b)
-  end
-
-  def on_while_mod(a, b)
-    Node.new('while_mod', a, b)
-  end
-
-  def on_word_add(a, b)
-    Node.new('word_add', a, b)
-  end
-
-  def on_word_new
-    Node.new('word_new')
-  end
-
-  def on_words_add(a, b)
-    Node.new('words_add', a, b)
-  end
-
-  def on_words_new
-    Node.new('words_new')
-  end
-
-  def on_xstring_add(a, b)
-    Node.new('xstring_add', a, b)
-  end
-
-  def on_xstring_literal(a)
-    Node.new('xstring_literal', a)
-  end
-
-  def on_xstring_new
-    Node.new('xstring_new')
-  end
-
-  def on_yield(a)
-    Node.new('yield', a)
-  end
-
-  def on_yield0
-    Node.new('yield0')
-  end
-
-  def on_zsuper
-    Node.new('zsuper')
-  end
-
-  def on_backref(a)
-    a
-  end
-  def on_comma(a)
-    a
-  end
-  def on_gvar(a)
-    a
-  end
-  def on_ident(a)
-    a
-  end
-  def on_int(a)
-    a
-  end
-  def on_kw(a)
-    a
-  end
-  def on_lbrace(a)
-    a
-  end
-  def on_rbrace(a)
-    a
-  end
-  def on_lbracket(a)
-    a
-  end
-  def on_rbracket(a)
-    a
-  end
-  def on_lparen(a)
-    a
-  end
-  def on_rparen(a)
-    a
-  end
-  def on_op(a)
-    a
-  end
-  def on_semicolon(a)
-    a
-  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]