Project

General

Profile

Bug #19563 ยป 0001-Bug-19563-Yield-words-separators-per-lines.patch

nobu (Nobuyoshi Nakada), 04/01/2023 01:44 PM

View differences:

parse.y
}
;
words : tWORDS_BEG ' ' word_list tSTRING_END
words_sep : ' ' {}
| words_sep ' '
;
words : tWORDS_BEG words_sep word_list tSTRING_END
{
/*%%%*/
$$ = make_list($3, &@$);
......
/*% %*/
/*% ripper: words_new! %*/
}
| word_list word ' '
| word_list word words_sep
{
/*%%%*/
$$ = list_append(p, $1, evstr2dstr(p, $2));
......
}
;
symbols : tSYMBOLS_BEG ' ' symbol_list tSTRING_END
symbols : tSYMBOLS_BEG words_sep symbol_list tSTRING_END
{
/*%%%*/
$$ = make_list($3, &@$);
......
/*% %*/
/*% ripper: symbols_new! %*/
}
| symbol_list word ' '
| symbol_list word words_sep
{
/*%%%*/
$$ = symbol_append(p, $1, evstr2dstr(p, $2));
......
}
;
qwords : tQWORDS_BEG ' ' qword_list tSTRING_END
qwords : tQWORDS_BEG words_sep qword_list tSTRING_END
{
/*%%%*/
$$ = make_list($3, &@$);
......
}
;
qsymbols : tQSYMBOLS_BEG ' ' qsym_list tSTRING_END
qsymbols : tQSYMBOLS_BEG words_sep qsym_list tSTRING_END
{
/*%%%*/
$$ = make_list($3, &@$);
......
/*% %*/
/*% ripper: qwords_new! %*/
}
| qword_list tSTRING_CONTENT ' '
| qword_list tSTRING_CONTENT words_sep
{
/*%%%*/
$$ = list_append(p, $1, $2);
......
/*% %*/
/*% ripper: qsymbols_new! %*/
}
| qsym_list tSTRING_CONTENT ' '
| qsym_list tSTRING_CONTENT words_sep
{
/*%%%*/
$$ = symbol_append(p, $1, $2);
......
}
c = nextc(p);
if ((func & STR_FUNC_QWORDS) && ISSPACE(c)) {
do {c = nextc(p);} while (ISSPACE(c));
ruby_debug_breakpoint();
while (c != '\n' && ISSPACE(c = nextc(p)));
space = 1;
}
if (func & STR_FUNC_LIST) {
......
return parser_string_term(p, func);
}
if (space) {
pushback(p, c);
if (!ISSPACE(c)) pushback(p, c);
add_delayed_token(p, p->lex.ptok, p->lex.pcur, __LINE__);
return ' ';
}
test/ripper/test_scanner_events.rb
scan('words_sep', '%w( w w w )')
assert_equal [' ', "\n", ' ', ' '],
scan('words_sep', "%w( w\nw w )")
assert_equal ["\n\n", "\n ", ' ', ' '],
assert_equal ["\n", "\n", "\n", ' ', ' ', ' '],
scan('words_sep', "%w(\n\nw\n w w )")
end
    (1-1/1)