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

ruby-changes:56104

From: Nobuyoshi <ko1@a...>
Date: Thu, 13 Jun 2019 22:06:42 +0900 (JST)
Subject: [ruby-changes:56104] Nobuyoshi Nakada: 043f010c28 (trunk): parse.y: moved pipeline to expr

https://git.ruby-lang.org/ruby.git/commit/?id=043f010c28

From 043f010c28e82ea38978bf8ed885416f133b5b75 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 13 Jun 2019 22:03:10 +0900
Subject: parse.y: moved pipeline to expr

To allow arguments without parentheses.

diff --git a/parse.y b/parse.y
index 6f282d8..a31139f 100644
--- a/parse.y
+++ b/parse.y
@@ -1496,6 +1496,37 @@ expr		: command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1496
 			$$ = call_uni_op(p, method_cond(p, $2, &@2), '!', &@1, &@$);
 		    }
 		| arg
+		| pipeline
+		;
+
+pipeline	: expr tPIPE operation2 opt_paren_args
+		    {
+		    /*%%%*/
+			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
+		    /*% %*/
+		    /*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
+		    }
+		| expr tPIPE operation2 opt_paren_args brace_block
+		    {
+		    /*%%%*/
+			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
+		    /*% %*/
+		    /*% ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
+		    }
+		| expr tPIPE operation2 command_args
+		    {
+		    /*%%%*/
+			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
+		    /*% %*/
+		    /*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
+		    }
+		| expr tPIPE operation2 command_args do_block
+		    {
+		    /*%%%*/
+			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
+		    /*% %*/
+		    /*% ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
+		    }
 		;
 
 expr_value	: expr
@@ -2271,29 +2302,12 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2302
 		    /*% %*/
 		    /*% ripper: ifop!($1, $3, $6) %*/
 		    }
-		| pipeline
 		| primary
 		    {
 			$$ = $1;
 		    }
 		;
 
-pipeline	: arg tPIPE operation2 opt_paren_args
-		    {
-		    /*%%%*/
-			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, Qnull, &@3, &@$);
-		    /*% %*/
-		    /*% ripper: command_call!($1, ID2VAL(idPIPE), $3, $4) %*/
-		    }
-		| arg tPIPE operation2 opt_paren_args brace_block
-		    {
-		    /*%%%*/
-			$$ = new_command_qcall(p, ID2VAL(idPIPE), $1, $3, $4, $5, &@3, &@$);
-		    /*% %*/
-		    /*% ripper: method_add_block!(command_call!($1, ID2VAL(idPIPE), $3, $4), $5) %*/
-		    }
-		;
-
 relop		: '>'  {$$ = '>';}
 		| '<'  {$$ = '<';}
 		| tGEQ {$$ = idGE;}
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 7bffb87..b3e2183 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1382,7 +1382,7 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1382
   def test_pipeline_operator
     assert_valid_syntax('x |> y')
     x = nil
-    assert_equal("121", eval('x = 12 |> pow(2) |> to_s(11)'))
+    assert_equal("121", eval('x = 12 |> pow(2) |> to_s 11'))
     assert_equal(12, x)
   end
 
-- 
cgit v0.10.2


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

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