From 68e16ddd7961b86e5013e62ae2954e88638de058 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 12 Nov 2015 05:17:06 +0000 Subject: [PATCH] parse.y: ANDDOT fluent interface * parse.y (parser_yylex): ANDDOT at the head of the line denote line continuation from previous one to support fluent interface, as well as single dot. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ misc/ruby-mode.el | 2 +- parse.y | 3 ++- test/ruby/test_syntax.rb | 5 +++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21b5f37fdf..f624163d4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Nov 12 14:17:01 2015 Nobuyoshi Nakada + + * parse.y (parser_yylex): ANDDOT at the head of the line denote + line continuation from previous one to support fluent interface, + as well as single dot. + Thu Nov 12 13:49:50 2015 SHIBATA Hiroshi * lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980). diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 026f541364..77371cf30f 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -898,7 +898,7 @@ Emacs to Ruby." (goto-char ruby-indent-point) (beginning-of-line) (skip-syntax-forward " ") - (if (looking-at "\\.[^.]") + (if (looking-at "\\.[^.]\\|&\\.") (+ indent ruby-indent-level) indent)))) diff --git a/parse.y b/parse.y index 0dc04783b9..56e424359c 100644 --- a/parse.y +++ b/parse.y @@ -8034,9 +8034,10 @@ parser_yylex(struct parser_params *parser) case '\13': /* '\v' */ space_seen = 1; break; + case '&': case '.': { dispatch_delayed_token(tIGNORED_NL); - if (!peek('.')) { + if (peek('.') == (c == '&')) { pushback(c); dispatch_scan_event(tSP); goto retry; diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 1f76425cad..985a46b532 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -628,6 +628,11 @@ eom assert_syntax_error(":#\n foo", /unexpected ':'/) end + def test_fluent_dot + assert_valid_syntax("a\n.foo") + assert_valid_syntax("a\n&.foo") + end + private def not_label(x) @result = x; @not_label ||= nil end