Skip to content

Commit

Permalink
parse.y: ANDDOT fluent interface
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nobu committed Nov 12, 2015
1 parent 88edab8 commit 68e16dd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Thu Nov 12 14:17:01 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>

* 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 <hsbt@ruby-lang.org>

* lib/rubygems: Update to RubyGems 2.5.0+ HEAD(db78980).
Expand Down
2 changes: 1 addition & 1 deletion misc/ruby-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))))

Expand Down
3 changes: 2 additions & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ def test_invalid_symbol_space
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
Expand Down

0 comments on commit 68e16dd

Please sign in to comment.