Skip to content

Commit eedeec8

Browse files
committed
Use current_string to handle :" symbols
1 parent fadb5be commit eedeec8

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/prism.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10946,7 +10946,15 @@ parse_symbol(pm_parser_t *parser, pm_lex_mode_t *lex_mode, pm_lex_state_t next_s
1094610946
}
1094710947

1094810948
// Now we can parse the first part of the symbol.
10949-
pm_node_t *part = parse_string_part(parser);
10949+
pm_node_t *part;
10950+
if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
10951+
pm_token_t opening = not_provided(parser);
10952+
pm_token_t closing = not_provided(parser);
10953+
part = (pm_node_t *) pm_string_node_create_current_string(parser, &opening, &parser->current, &closing);
10954+
parser_lex(parser);
10955+
} else {
10956+
part = parse_string_part(parser);
10957+
}
1095010958

1095110959
// If we got a string part, then it's possible that we could transform
1095210960
// what looks like an interpolated symbol into a regular symbol.
@@ -10963,7 +10971,16 @@ parse_symbol(pm_parser_t *parser, pm_lex_mode_t *lex_mode, pm_lex_state_t next_s
1096310971
if (part) pm_node_list_append(&node_list, part);
1096410972

1096510973
while (!match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
10966-
if ((part = parse_string_part(parser)) != NULL) {
10974+
if (match1(parser, PM_TOKEN_STRING_CONTENT)) {
10975+
pm_token_t opening = not_provided(parser);
10976+
pm_token_t closing = not_provided(parser);
10977+
part = (pm_node_t *) pm_string_node_create_current_string(parser, &opening, &parser->current, &closing);
10978+
parser_lex(parser);
10979+
} else {
10980+
part = parse_string_part(parser);
10981+
}
10982+
10983+
if (part != NULL) {
1096710984
pm_node_list_append(&node_list, part);
1096810985
}
1096910986
}

test/prism/unescape_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def prism_result(escape) = prism(escape, &:unescaped)
134134
[Context::List.new("%I[", "]"), escapes],
135135
[Context::Symbol.new("%s[", "]"), escapes],
136136
[Context::Symbol.new(":'", "'"), escapes],
137-
# [Context::Symbol.new(":\"", "\""), escapes],
137+
[Context::Symbol.new(":\"", "\""), escapes],
138138
# [Context::RegExp.new("/", "/"), escapes],
139139
# [Context::RegExp.new("%r[", "]"), escapes]
140140
]

0 commit comments

Comments
 (0)