@@ -4860,8 +4860,6 @@ pm_yield_node_create(pm_parser_t *parser, const pm_token_t *keyword, const pm_lo
4860
4860
return node;
4861
4861
}
4862
4862
4863
-
4864
- #undef PM_EMPTY_STRING
4865
4863
#undef PM_ALLOC_NODE
4866
4864
4867
4865
/******************************************************************************/
@@ -6099,6 +6097,7 @@ lex_question_mark(pm_parser_t *parser) {
6099
6097
6100
6098
if (parser->current.end >= parser->end) {
6101
6099
pm_parser_err_current(parser, PM_ERR_INCOMPLETE_QUESTION_MARK);
6100
+ pm_string_shared_init(&parser->current_string, parser->current.start + 1, parser->current.end);
6102
6101
return PM_TOKEN_CHARACTER_LITERAL;
6103
6102
}
6104
6103
@@ -6112,6 +6111,8 @@ lex_question_mark(pm_parser_t *parser) {
6112
6111
if (parser->current.start[1] == '\\') {
6113
6112
lex_state_set(parser, PM_LEX_STATE_END);
6114
6113
parser->current.end += pm_unescape_calculate_difference(parser, parser->current.start + 1, PM_UNESCAPE_ALL, true);
6114
+ pm_string_shared_init(&parser->current_string, parser->current.start + 1, parser->current.end);
6115
+ pm_unescape_manipulate_char_literal(parser, &parser->current_string, PM_UNESCAPE_ALL);
6115
6116
return PM_TOKEN_CHARACTER_LITERAL;
6116
6117
} else {
6117
6118
size_t encoding_width = parser->encoding.char_width(parser->current.end, parser->end - parser->current.end);
@@ -6128,6 +6129,7 @@ lex_question_mark(pm_parser_t *parser) {
6128
6129
) {
6129
6130
lex_state_set(parser, PM_LEX_STATE_END);
6130
6131
parser->current.end += encoding_width;
6132
+ pm_string_shared_init(&parser->current_string, parser->current.start + 1, parser->current.end);
6131
6133
return PM_TOKEN_CHARACTER_LITERAL;
6132
6134
}
6133
6135
}
@@ -8077,17 +8079,6 @@ pm_symbol_node_create_and_unescape(pm_parser_t *parser, const pm_token_t *openin
8077
8079
return node;
8078
8080
}
8079
8081
8080
- static pm_string_node_t *
8081
- pm_char_literal_node_create_and_unescape(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing, pm_unescape_type_t unescape_type) {
8082
- pm_string_node_t *node = pm_string_node_create(parser, opening, content, closing);
8083
-
8084
- assert((content->end - content->start) >= 0);
8085
- pm_string_shared_init(&node->unescaped, content->start, content->end);
8086
-
8087
- pm_unescape_manipulate_char_literal(parser, &node->unescaped, unescape_type);
8088
- return node;
8089
- }
8090
-
8091
8082
static pm_string_node_t *
8092
8083
pm_string_node_create_and_unescape(pm_parser_t *parser, const pm_token_t *opening, const pm_token_t *content, const pm_token_t *closing, pm_unescape_type_t unescape_type) {
8093
8084
pm_string_node_t *node = pm_string_node_create(parser, opening, content, closing);
@@ -11763,16 +11754,17 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) {
11763
11754
content.start = content.start + 1;
11764
11755
11765
11756
pm_token_t closing = not_provided(parser);
11766
- pm_node_t *node = (pm_node_t *) pm_char_literal_node_create_and_unescape(parser, &opening, &content, &closing, PM_UNESCAPE_ALL);
11757
+ pm_string_node_t *node = (pm_string_node_t *) pm_string_node_create(parser, &opening, &content, &closing);
11758
+ node->unescaped = parser->current_string;
11767
11759
11768
11760
// Characters can be followed by strings in which case they are
11769
11761
// automatically concatenated.
11770
11762
if (match1(parser, PM_TOKEN_STRING_BEGIN)) {
11771
11763
pm_node_t *concat = parse_strings(parser);
11772
- return (pm_node_t *) pm_string_concat_node_create(parser, node, concat);
11764
+ return (pm_node_t *) pm_string_concat_node_create(parser, (pm_node_t *) node, concat);
11773
11765
}
11774
11766
11775
- return node;
11767
+ return (pm_node_t *) node;
11776
11768
}
11777
11769
case PM_TOKEN_CLASS_VARIABLE: {
11778
11770
parser_lex(parser);
@@ -14538,6 +14530,7 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const ch
14538
14530
.constant_pool = PM_CONSTANT_POOL_EMPTY,
14539
14531
.newline_list = PM_NEWLINE_LIST_EMPTY,
14540
14532
.integer_base = 0,
14533
+ .current_string = PM_EMPTY_STRING,
14541
14534
.command_start = true,
14542
14535
.recovering = false,
14543
14536
.encoding_changed = false,
@@ -14675,10 +14668,11 @@ pm_parse_serialize(const uint8_t *source, size_t size, pm_buffer_t *buffer, cons
14675
14668
pm_parser_free(&parser);
14676
14669
}
14677
14670
14678
- #undef PM_LOCATION_NULL_VALUE
14679
- #undef PM_LOCATION_TOKEN_VALUE
14680
- #undef PM_LOCATION_NODE_VALUE
14681
- #undef PM_LOCATION_NODE_BASE_VALUE
14682
14671
#undef PM_CASE_KEYWORD
14683
14672
#undef PM_CASE_OPERATOR
14684
14673
#undef PM_CASE_WRITABLE
14674
+ #undef PM_EMPTY_STRING
14675
+ #undef PM_LOCATION_NODE_BASE_VALUE
14676
+ #undef PM_LOCATION_NODE_VALUE
14677
+ #undef PM_LOCATION_NULL_VALUE
14678
+ #undef PM_LOCATION_TOKEN_VALUE
0 commit comments