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

ruby-changes:18535

From: yugui <ko1@a...>
Date: Sun, 16 Jan 2011 15:30:58 +0900 (JST)
Subject: [ruby-changes:18535] Ruby:r30558 (ruby_1_9_2): merges r30381 from trunk into ruby_1_9_2.

yugui	2011-01-16 15:30:28 +0900 (Sun, 16 Jan 2011)

  New Revision: 30558

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

  Log:
    merges r30381 from trunk into ruby_1_9_2.
    --
    * parse.y (stmt): missing ripper rule.  i.e., `a::B ||= c 1'.
      http://twitter.com/#!/wannabe53/status/18797576396472321
      http://twitter.com/#!/wannabe53/status/18798416150663168

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/parse.y
    branches/ruby_1_9_2/test/ripper/dummyparser.rb
    branches/ruby_1_9_2/test/ripper/test_parser_events.rb
    branches/ruby_1_9_2/version.h

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 30557)
+++ ruby_1_9_2/ChangeLog	(revision 30558)
@@ -1,3 +1,9 @@
+Sun Dec 26 11:39:11 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (stmt): missing ripper rule.  i.e., `a::B ||= c 1'.
+	  http://twitter.com/#!/wannabe53/status/18797576396472321
+	  http://twitter.com/#!/wannabe53/status/18798416150663168
+
 Sun Dec 26 04:31:15 2010  Luis Lavena  <luislavena@g...>
 
 	* ext/dl/win32/registry.rb: Corrected RegCreateKeyExA signature.
Index: ruby_1_9_2/parse.y
===================================================================
--- ruby_1_9_2/parse.y	(revision 30557)
+++ ruby_1_9_2/parse.y	(revision 30558)
@@ -1171,8 +1171,14 @@
 		    }
 		| primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
 		    {
+		    /*%%%*/
 			yyerror("constant re-assignment");
 			$$ = 0;
+		    /*%
+			$$ = dispatch2(const_path_field, $1, $3);
+			$$ = dispatch3(opassign, $$, $4, $5);
+			$$ = dispatch1(assign_error, $$);
+		    %*/
 		    }
 		| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
 		    {
Index: ruby_1_9_2/version.h
===================================================================
--- ruby_1_9_2/version.h	(revision 30557)
+++ ruby_1_9_2/version.h	(revision 30558)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 140
+#define RUBY_PATCHLEVEL 141
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1
Index: ruby_1_9_2/test/ripper/test_parser_events.rb
===================================================================
--- ruby_1_9_2/test/ripper/test_parser_events.rb	(revision 30557)
+++ ruby_1_9_2/test/ripper/test_parser_events.rb	(revision 30558)
@@ -20,7 +20,7 @@
 
   def parse(str, nm = nil, &bl)
     dp = DummyParser.new(str)
-    dp.hook(nm, &bl) if nm
+    dp.hook(*nm, &bl) if nm
     dp.parse.to_s
   end
 
@@ -347,10 +347,10 @@
     assert_equal true, thru_heredoc_beg
     assert_match(/string_content\(\),heredoc\n/, tree, bug1921)
     heredoc = nil
-    parse("<<EOS\nheredoc1\nheredoc2\nEOS\n", :on_string_add) {|n, s| heredoc = s}
+    parse("<<EOS\nheredoc1\nheredoc2\nEOS\n", :on_string_add) {|e, n, s| heredoc = s}
     assert_equal("heredoc1\nheredoc2\n", heredoc, bug1921)
     heredoc = nil
-    parse("<<-EOS\nheredoc1\nheredoc2\n\tEOS\n", :on_string_add) {|n, s| heredoc = s}
+    parse("<<-EOS\nheredoc1\nheredoc2\n\tEOS\n", :on_string_add) {|e, n, s| heredoc = s}
     assert_equal("heredoc1\nheredoc2\n", heredoc, bug1921)
   end
 
@@ -676,6 +676,15 @@
     assert_equal true, thru_opassign
   end
 
+  def test_opassign_error
+    thru_opassign = []
+    events = [:on_opassign, :on_assign_error]
+    parse('a::X ||= c 1', events) {|a,*b|
+      thru_opassign << a
+    }
+    assert_equal events, thru_opassign
+  end
+
   def test_param_error
     thru_param_error = false
     parse('def foo(A) end', :on_param_error) {thru_param_error = true}
@@ -1104,7 +1113,7 @@
 
   def test_unterminated_regexp
     compile_error = false
-    parse('/', :compile_error) {|msg| compile_error = msg}
+    parse('/', :compile_error) {|e, msg| compile_error = msg}
     assert_equal("unterminated regexp meets end of file", compile_error)
   end
 end if ripper_test
Index: ruby_1_9_2/test/ripper/dummyparser.rb
===================================================================
--- ruby_1_9_2/test/ripper/dummyparser.rb	(revision 30557)
+++ ruby_1_9_2/test/ripper/dummyparser.rb	(revision 30558)
@@ -10,7 +10,7 @@
     @children = nodes
   end
 
-  attr_reader :children
+  attr_reader :name, :children
 
   def to_s
     "#{@name}(#{Node.trim_nil(@children).map {|n| n.to_s }.join(',')})"
@@ -47,12 +47,14 @@
 end
 
 class DummyParser < Ripper
-  def hook(name)
+  def hook(*names)
     class << self; self; end.class_eval do
-      define_method(name) do |*a, &b|
-        result = super(*a, &b)
-        yield(*a)
-        result
+      names.each do |name|
+        define_method(name) do |*a, &b|
+          result = super(*a, &b)
+          yield(name, *a)
+          result
+        end
       end
     end
     self

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

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