ruby-changes:56115
From: Nobuyoshi <ko1@a...>
Date: Sat, 15 Jun 2019 12:04:35 +0900 (JST)
Subject: [ruby-changes:56115] Nobuyoshi Nakada: 5d79054906 (trunk): Revert github/pull/2230, commit miss
https://git.ruby-lang.org/ruby.git/commit/?id=5d79054906 From 5d7905490659b9b4f4604e9fd479563fcd103b34 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 15 Jun 2019 12:04:16 +0900 Subject: Revert github/pull/2230, commit miss diff --git a/parse.y b/parse.y index 1ce75fd..a7cdddc 100644 --- a/parse.y +++ b/parse.y @@ -91,7 +91,6 @@ enum lex_state_bits { https://github.com/ruby/ruby/blob/trunk/parse.y#L91 EXPR_LABEL_bit, /* flag bit, label is allowed. */ EXPR_LABELED_bit, /* flag bit, just after a label. */ EXPR_FITEM_bit, /* symbol literal as FNAME. */ - EXPR_EMPTYLN_bit, /* line contains only whitespace and comments */ EXPR_MAX_STATE }; /* examine combinations */ @@ -110,7 +109,6 @@ enum lex_state_e { https://github.com/ruby/ruby/blob/trunk/parse.y#L109 DEF_EXPR(LABEL), DEF_EXPR(LABELED), DEF_EXPR(FITEM), - DEF_EXPR(EMPTYLN), EXPR_VALUE = EXPR_BEG, EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS), EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG), @@ -8680,11 +8678,6 @@ parser_yylex(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L8678 case '\13': /* '\v' */ space_seen = 1; break; - case '\n': - case '#': - SET_LEX_STATE(EXPR_EMPTYLN); - pushback(p, c); - goto retry; case '|': case '&': case '.': { @@ -10023,7 +10016,7 @@ new_regexp(struct parser_params *p, VALUE re, VALUE opt, const YYLTYPE *loc) https://github.com/ruby/ruby/blob/trunk/parse.y#L10016 static const char rb_parser_lex_state_names[][13] = { "EXPR_BEG", "EXPR_END", "EXPR_ENDARG", "EXPR_ENDFN", "EXPR_ARG", "EXPR_CMDARG", "EXPR_MID", "EXPR_FNAME", "EXPR_DOT", "EXPR_CLASS", - "EXPR_LABEL", "EXPR_LABELED","EXPR_FITEM", "EXPR_EMPTYLN", + "EXPR_LABEL", "EXPR_LABELED","EXPR_FITEM", }; static VALUE diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 776711c..4e8ffe5 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -981,34 +981,6 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L981 assert_syntax_error("a&.x,=0", /multiple assignment destination/) end - def test_fluent_dot_with_empty_lines_between - assert_valid_syntax("a #\n #\n.foo") - assert_valid_syntax("a #\n #\n&.foo") - assert_valid_syntax("a\n\n.foo") - assert_valid_syntax("a \n \n &.foo") - - src = <<~RUBY - def m - # c - - x - end - RUBY - tokens = [ - [:on_kw, "def", ], # EXPR_FNAME], - [:on_sp, " ", ], # EXPR_FNAME], - [:on_ident, "m", ], # EXPR_ENDFN], - [:on_nl, "\n", ], # EXPR_BEG], - [:on_comment, " # c\n", ], # EXPR_EMPTYLN], - [:on_sp, " ", ], # EXPR_BEG], - [:on_ident, "x", ], # EXPR_CMDARG], - [:on_nl, "\n", ], # EXPR_BEG], - [:on_kw, "end", ], # EXPR_END], - [:on_nl, "\n", ], # EXPR_BEG], - ] - assert_tokens tokens, src - end - def test_no_warning_logop_literal assert_warning("") do eval("true||raise;nil") @@ -1425,17 +1397,6 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1397 assert_equal(expected, @result, message) end - def assert_tokens(expected, src, message = nil) - begin - require 'ripper' - actual = Ripper.lex(src).map { |_position, type, value, _state| [type, value] } - assert_equal(expected, actual, message) - rescue Exception => err - puts err - exit! 1 - end - end - def make_tmpsrc(f, src) f.open f.truncate(0) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/