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

ruby-changes:57759

From: Nobuyoshi <ko1@a...>
Date: Sun, 15 Sep 2019 23:16:09 +0900 (JST)
Subject: [ruby-changes:57759] 3a3f48fb8f (master): Comment lines can be placed between fluent dot now

https://git.ruby-lang.org/ruby.git/commit/?id=3a3f48fb8f

From 3a3f48fb8fbdbb810d9b675159529970015316b9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 15 Sep 2019 23:12:24 +0900
Subject: Comment lines can be placed between fluent dot now


diff --git a/NEWS b/NEWS
index 3848b6d..aa9919d 100644
--- a/NEWS
+++ b/NEWS
@@ -71,6 +71,12 @@ sufficient information, see the ChangeLog file or Redmine https://github.com/ruby/ruby/blob/trunk/NEWS#L71
 
 * The flip-flop syntax deprecation is reverted. [Feature #5400]
 
+* Comment lines can be placed between fluent dot now.
+
+    foo
+      # .bar
+      .baz # => foo.baz
+
 === Core classes updates (outstanding ones only)
 
 Complex::
diff --git a/parse.y b/parse.y
index 60fcf8c..c4fad93 100644
--- a/parse.y
+++ b/parse.y
@@ -8737,6 +8737,10 @@ parser_yylex(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L8737
 	      case '\13': /* '\v' */
 		space_seen = 1;
 		break;
+	      case '#':
+		pushback(p, c);
+		if (space_seen) dispatch_scan_event(p, tSP);
+		goto retry;
 	      case '&':
 	      case '.': {
 		dispatch_delayed_token(p, tIGNORED_NL);
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index a904b0d..ec6fc25 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1033,6 +1033,9 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1033
     assert_valid_syntax("a\n.foo")
     assert_valid_syntax("a\n&.foo")
     assert_valid_syntax("a\n.:foo")
+    assert_valid_syntax("a #\n#\n.foo\n")
+    assert_valid_syntax("a #\n#\n&.foo\n")
+    assert_valid_syntax("a #\n#\n.:foo\n")
   end
 
   def test_safe_call_in_massign_lhs
-- 
cgit v0.10.2


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

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