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

ruby-changes:47130

From: nobu <ko1@a...>
Date: Sat, 1 Jul 2017 10:51:21 +0900 (JST)
Subject: [ruby-changes:47130] nobu:r59245 (trunk): parse.y: mlhs_add_post

nobu	2017-07-01 10:51:17 +0900 (Sat, 01 Jul 2017)

  New Revision: 59245

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59245

  Log:
    parse.y: mlhs_add_post
    
    * parse.y (mlhs_add_post): new parser event corresponding to
      POSTARG.

  Modified files:
    trunk/parse.y
    trunk/test/ripper/test_parser_events.rb
Index: test/ripper/test_parser_events.rb
===================================================================
--- test/ripper/test_parser_events.rb	(revision 59244)
+++ test/ripper/test_parser_events.rb	(revision 59245)
@@ -474,19 +474,42 @@ class TestRipper::ParserEvents < Test::U https://github.com/ruby/ruby/blob/trunk/test/ripper/test_parser_events.rb#L474
     thru_mlhs_add_star = false
     tree = parse("a, *b, c = 1, 2", :on_mlhs_add_star) {thru_mlhs_add_star = true}
     assert_equal true, thru_mlhs_add_star
-    assert_include(tree, "massign([a,*b,[c]]", bug2232)
+    assert_include(tree, "massign([a,*b,c]", bug2232)
     thru_mlhs_add_star = false
     tree = parse("a, *, c = 1, 2", :on_mlhs_add_star) {thru_mlhs_add_star = true}
     assert_equal true, thru_mlhs_add_star
-    assert_include(tree, "massign([a,*,[c]]", bug4364)
+    assert_include(tree, "massign([a,*,c]", bug4364)
     thru_mlhs_add_star = false
     tree = parse("*b, c = 1, 2", :on_mlhs_add_star) {thru_mlhs_add_star = true}
     assert_equal true, thru_mlhs_add_star
-    assert_include(tree, "massign([*b,[c]]", bug4364)
+    assert_include(tree, "massign([*b,c]", bug4364)
     thru_mlhs_add_star = false
     tree = parse("*, c = 1, 2", :on_mlhs_add_star) {thru_mlhs_add_star = true}
     assert_equal true, thru_mlhs_add_star
-    assert_include(tree, "massign([*,[c]],", bug4364)
+    assert_include(tree, "massign([*,c],", bug4364)
+  end
+
+  def test_mlhs_add_post
+    thru_mlhs_add_post = false
+    tree = parse("a, *b = 1, 2", :on_mlhs_add_post) {thru_mlhs_add_post = true}
+    assert_equal false, thru_mlhs_add_post
+    assert_include(tree, "massign([a,*b],")
+    thru_massign_add_post = false
+    tree = parse("a, *b, c = 1, 2", :on_mlhs_add_post) {thru_mlhs_add_post = true}
+    assert_equal true, thru_mlhs_add_post
+    assert_include(tree, "massign([a,*b,c],")
+    thru_mlhs_add_post = false
+    tree = parse("a, *, c = 1, 2", :on_mlhs_add_post) {thru_mlhs_add_post = true}
+    assert_equal true, thru_mlhs_add_post
+    assert_include(tree, "massign([a,*,c],")
+    thru_mlhs_add_post = false
+    tree = parse("*b, c = 1, 2", :on_mlhs_add_post) {thru_mlhs_add_post = true}
+    assert_equal true, thru_mlhs_add_post
+    assert_include(tree, "massign([*b,c],")
+    thru_mlhs_add_post = false
+    tree = parse("*, c = 1, 2", :on_mlhs_add_post) {thru_mlhs_add_post = true}
+    assert_equal true, thru_mlhs_add_post
+    assert_include(tree, "massign([*,c],")
   end
 
   def test_mlhs_new
Index: parse.y
===================================================================
--- parse.y	(revision 59244)
+++ parse.y	(revision 59245)
@@ -691,13 +691,12 @@ static void ripper_error_gen(struct pars https://github.com/ruby/ruby/blob/trunk/parse.y#L691
 #define mlhs_new() dispatch0(mlhs_new)
 #define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
 #define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
+#define mlhs_add_post(l,a) dispatch2(mlhs_add_post, (l), (a))
 
 #define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
         dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
 
 #define blockvar_new(p,v) dispatch2(block_var, (p), (v))
-#define blockvar_add_star(l,a) dispatch2(block_var_add_star, (l), (a))
-#define blockvar_add_block(l,a) dispatch2(block_var_add_block, (l), (a))
 
 #define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
 #define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
@@ -1602,7 +1601,7 @@ mlhs_basic	: mlhs_head https://github.com/ruby/ruby/blob/trunk/parse.y#L1601
 			$$ = NEW_MASGN($1, NEW_POSTARG($3,$5));
 		    /*%
 			$1 = mlhs_add_star($1, $3);
-			$$ = mlhs_add($1, $5);
+			$$ = mlhs_add_post($1, $5);
 		    %*/
 		    }
 		| mlhs_head tSTAR
@@ -1619,7 +1618,7 @@ mlhs_basic	: mlhs_head https://github.com/ruby/ruby/blob/trunk/parse.y#L1618
 			$$ = NEW_MASGN($1, NEW_POSTARG(-1, $4));
 		    /*%
 			$1 = mlhs_add_star($1, Qnil);
-			$$ = mlhs_add($1, $4);
+			$$ = mlhs_add_post($1, $4);
 		    %*/
 		    }
 		| tSTAR mlhs_node
@@ -1636,7 +1635,7 @@ mlhs_basic	: mlhs_head https://github.com/ruby/ruby/blob/trunk/parse.y#L1635
 			$$ = NEW_MASGN(0, NEW_POSTARG($2,$4));
 		    /*%
 			$2 = mlhs_add_star(mlhs_new(), $2);
-			$$ = mlhs_add($2, $4);
+			$$ = mlhs_add_post($2, $4);
 		    %*/
 		    }
 		| tSTAR
@@ -1653,7 +1652,7 @@ mlhs_basic	: mlhs_head https://github.com/ruby/ruby/blob/trunk/parse.y#L1652
 			$$ = NEW_MASGN(0, NEW_POSTARG(-1, $3));
 		    /*%
 			$$ = mlhs_add_star(mlhs_new(), Qnil);
-			$$ = mlhs_add($$, $3);
+			$$ = mlhs_add_post($$, $3);
 		    %*/
 		    }
 		;

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

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