зеркало из https://github.com/github/ruby.git
[ruby/yarp] fix: %i list spanning a heredoc
The fix here is similar to what we did in a previous commit for %w, to accept two consecutive string tokens without a separator. https://github.com/ruby/yarp/commit/f869fbdbe5
This commit is contained in:
Родитель
74812df496
Коммит
29c5b85128
|
@ -36,3 +36,9 @@ pp <<-A, %W[l\
|
|||
k
|
||||
A
|
||||
l]
|
||||
|
||||
# ripper can't parse this successfully, though ruby runs it correctly
|
||||
pp <<-A, %i[n\
|
||||
m
|
||||
A
|
||||
n]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
ProgramNode(164...709)(
|
||||
ProgramNode(164...802)(
|
||||
[],
|
||||
StatementsNode(164...709)(
|
||||
StatementsNode(164...802)(
|
||||
[CallNode(164...192)(
|
||||
nil,
|
||||
nil,
|
||||
|
@ -160,6 +160,29 @@ ProgramNode(164...709)(
|
|||
nil,
|
||||
0,
|
||||
"pp"
|
||||
),
|
||||
CallNode(781...802)(
|
||||
nil,
|
||||
nil,
|
||||
(781...783),
|
||||
nil,
|
||||
ArgumentsNode(784...802)(
|
||||
[InterpolatedStringNode(784...788)(
|
||||
(784...788),
|
||||
[StringNode(796...798)(nil, (796...798), nil, "m\n")],
|
||||
(798...800)
|
||||
),
|
||||
ArrayNode(790...802)(
|
||||
[SymbolNode(793...796)(nil, (793...796), nil, "n\\\n"),
|
||||
SymbolNode(800...801)(nil, (800...801), nil, "n")],
|
||||
(790...793),
|
||||
(801...802)
|
||||
)]
|
||||
),
|
||||
nil,
|
||||
nil,
|
||||
0,
|
||||
"pp"
|
||||
)]
|
||||
)
|
||||
)
|
||||
|
|
|
@ -11944,14 +11944,9 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
|
|||
yp_array_node_t *array = yp_array_node_create(parser, &parser->previous);
|
||||
|
||||
while (!match_any_type_p(parser, 2, YP_TOKEN_STRING_END, YP_TOKEN_EOF)) {
|
||||
if (yp_array_node_size(array) == 0) {
|
||||
accept(parser, YP_TOKEN_WORDS_SEP);
|
||||
} else {
|
||||
expect(parser, YP_TOKEN_WORDS_SEP, "Expected a separator for the symbols in a `%i` list.");
|
||||
if (match_type_p(parser, YP_TOKEN_STRING_END)) break;
|
||||
}
|
||||
|
||||
accept(parser, YP_TOKEN_WORDS_SEP);
|
||||
if (match_type_p(parser, YP_TOKEN_STRING_END)) break;
|
||||
|
||||
expect(parser, YP_TOKEN_STRING_CONTENT, "Expected a symbol in a `%i` list.");
|
||||
|
||||
yp_token_t opening = not_provided(parser);
|
||||
|
|
Загрузка…
Ссылка в новой задаче