mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Revert github/pull/2230, commit miss
This commit is contained in:
parent
6fa4c90448
commit
5d79054906
2 changed files with 1 additions and 47 deletions
9
parse.y
9
parse.y
|
@ -91,7 +91,6 @@ enum lex_state_bits {
|
||||||
EXPR_LABEL_bit, /* flag bit, label is allowed. */
|
EXPR_LABEL_bit, /* flag bit, label is allowed. */
|
||||||
EXPR_LABELED_bit, /* flag bit, just after a label. */
|
EXPR_LABELED_bit, /* flag bit, just after a label. */
|
||||||
EXPR_FITEM_bit, /* symbol literal as FNAME. */
|
EXPR_FITEM_bit, /* symbol literal as FNAME. */
|
||||||
EXPR_EMPTYLN_bit, /* line contains only whitespace and comments */
|
|
||||||
EXPR_MAX_STATE
|
EXPR_MAX_STATE
|
||||||
};
|
};
|
||||||
/* examine combinations */
|
/* examine combinations */
|
||||||
|
@ -110,7 +109,6 @@ enum lex_state_e {
|
||||||
DEF_EXPR(LABEL),
|
DEF_EXPR(LABEL),
|
||||||
DEF_EXPR(LABELED),
|
DEF_EXPR(LABELED),
|
||||||
DEF_EXPR(FITEM),
|
DEF_EXPR(FITEM),
|
||||||
DEF_EXPR(EMPTYLN),
|
|
||||||
EXPR_VALUE = EXPR_BEG,
|
EXPR_VALUE = EXPR_BEG,
|
||||||
EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
|
EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
|
||||||
EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
|
EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
|
||||||
|
@ -8680,11 +8678,6 @@ parser_yylex(struct parser_params *p)
|
||||||
case '\13': /* '\v' */
|
case '\13': /* '\v' */
|
||||||
space_seen = 1;
|
space_seen = 1;
|
||||||
break;
|
break;
|
||||||
case '\n':
|
|
||||||
case '#':
|
|
||||||
SET_LEX_STATE(EXPR_EMPTYLN);
|
|
||||||
pushback(p, c);
|
|
||||||
goto retry;
|
|
||||||
case '|':
|
case '|':
|
||||||
case '&':
|
case '&':
|
||||||
case '.': {
|
case '.': {
|
||||||
|
@ -10023,7 +10016,7 @@ new_regexp(struct parser_params *p, VALUE re, VALUE opt, const YYLTYPE *loc)
|
||||||
static const char rb_parser_lex_state_names[][13] = {
|
static const char rb_parser_lex_state_names[][13] = {
|
||||||
"EXPR_BEG", "EXPR_END", "EXPR_ENDARG", "EXPR_ENDFN", "EXPR_ARG",
|
"EXPR_BEG", "EXPR_END", "EXPR_ENDARG", "EXPR_ENDFN", "EXPR_ARG",
|
||||||
"EXPR_CMDARG", "EXPR_MID", "EXPR_FNAME", "EXPR_DOT", "EXPR_CLASS",
|
"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
|
static VALUE
|
||||||
|
|
|
@ -981,34 +981,6 @@ eom
|
||||||
assert_syntax_error("a&.x,=0", /multiple assignment destination/)
|
assert_syntax_error("a&.x,=0", /multiple assignment destination/)
|
||||||
end
|
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
|
def test_no_warning_logop_literal
|
||||||
assert_warning("") do
|
assert_warning("") do
|
||||||
eval("true||raise;nil")
|
eval("true||raise;nil")
|
||||||
|
@ -1425,17 +1397,6 @@ eom
|
||||||
assert_equal(expected, @result, message)
|
assert_equal(expected, @result, message)
|
||||||
end
|
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)
|
def make_tmpsrc(f, src)
|
||||||
f.open
|
f.open
|
||||||
f.truncate(0)
|
f.truncate(0)
|
||||||
|
|
Loading…
Reference in a new issue