diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2023-10-10 14:22:23 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2023-10-13 15:31:30 -0400 |
| commit | 41ac8ddca34445076aba16504e1eeacae3cefed5 (patch) | |
| tree | 4886d5a8bfa7f927d5b22fc0a3f702bcad47528f | |
| parent | 3c743445d727b2e1444c5aae4113056de4bdd530 (diff) | |
[ruby/prism] Extract out string handling for %W lists
https://github.com/ruby/prism/commit/dba9bd6b1f
| -rw-r--r-- | prism/prism.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/prism/prism.c b/prism/prism.c index 24789dd27e..bf1c696be2 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -13597,29 +13597,28 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) { break; } case PM_TOKEN_STRING_CONTENT: { + parser_lex(parser); + pm_token_t opening = not_provided(parser); + pm_token_t closing = not_provided(parser); + pm_string_node_t *string = (pm_string_node_t *) pm_string_node_create_and_unescape(parser, &opening, &parser->previous, &closing, PM_UNESCAPE_ALL); + if (current == NULL) { // If we hit content and the current node is NULL, then this is // the first string content we've seen. In that case we're going // to create a new string node and set that to the current. - current = parse_string_part(parser); + current = (pm_node_t *) string; } else if (PM_NODE_TYPE_P(current, PM_INTERPOLATED_STRING_NODE)) { // If we hit string content and the current node is an // interpolated string, then we need to append the string content // to the list of child nodes. - pm_node_t *part = parse_string_part(parser); - pm_interpolated_string_node_append((pm_interpolated_string_node_t *) current, part); + pm_interpolated_string_node_append((pm_interpolated_string_node_t *) current, (pm_node_t *) string); } else if (PM_NODE_TYPE_P(current, PM_STRING_NODE)) { // If we hit string content and the current node is a string node, // then we need to convert the current node into an interpolated // string and add the string content to the list of child nodes. - pm_token_t opening = not_provided(parser); - pm_token_t closing = not_provided(parser); - pm_interpolated_string_node_t *interpolated = - pm_interpolated_string_node_create(parser, &opening, NULL, &closing); + pm_interpolated_string_node_t *interpolated = pm_interpolated_string_node_create(parser, &opening, NULL, &closing); pm_interpolated_string_node_append(interpolated, current); - - pm_node_t *part = parse_string_part(parser); - pm_interpolated_string_node_append(interpolated, part); + pm_interpolated_string_node_append(interpolated, (pm_node_t *) string); current = (pm_node_t *) interpolated; } else { assert(false && "unreachable"); |
