Skip to content

Commit 78d9f20

Browse files
committed
Fix up documentation for regexp structs
1 parent 11e0e20 commit 78d9f20

File tree

8 files changed

+37
-13
lines changed

8 files changed

+37
-13
lines changed

β€ŽGemfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ platforms :mri, :mswin, :mingw, :x64_mingw do
1616
gem "ruby_parser"
1717
end
1818

19-
gem "onigmo", platforms: [:mri]
19+
gem "onigmo", platforms: :ruby

β€Žgemfiles/2.7/Gemfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ruby "~> 2.7.0"
77
gemspec path: "../.."
88

99
gem "ffi"
10-
gem "onigmo"
10+
gem "onigmo", platforms: :ruby
1111
gem "parser"
1212
gem "rake-compiler"
1313
gem "rake"

β€Žgemfiles/3.0/Gemfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ruby "~> 3.0.0"
77
gemspec path: "../.."
88

99
gem "ffi"
10-
gem "onigmo"
10+
gem "onigmo", platforms: :ruby
1111
gem "parser"
1212
gem "rake-compiler"
1313
gem "rake"

β€Žgemfiles/3.1/Gemfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ruby "~> 3.1.0"
77
gemspec path: "../.."
88

99
gem "ffi"
10-
gem "onigmo"
10+
gem "onigmo", platforms: :ruby
1111
gem "parser"
1212
gem "rake-compiler"
1313
gem "rake"

β€Žgemfiles/3.2/Gemfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ruby "~> 3.2.0"
77
gemspec path: "../.."
88

99
gem "ffi"
10-
gem "onigmo"
10+
gem "onigmo", platforms: :ruby
1111
gem "parser"
1212
gem "rake-compiler"
1313
gem "rake"

β€Žgemfiles/3.3/Gemfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ruby "~> 3.3.0"
77
gemspec path: "../.."
88

99
gem "ffi"
10-
gem "onigmo"
10+
gem "onigmo", platforms: :ruby
1111
gem "parser"
1212
gem "rake-compiler"
1313
gem "rake"

β€Žgemfiles/3.4/Gemfileβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ruby "~> 3.4.0.dev"
77
gemspec path: "../.."
88

99
gem "ffi"
10-
gem "onigmo"
10+
gem "onigmo", platforms: :ruby
1111
gem "parser"
1212
gem "rake-compiler"
1313
gem "rake"

β€Žsrc/prism.cβ€Ž

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17407,9 +17407,21 @@ parse_yield(pm_parser_t *parser, const pm_node_t *node) {
1740717407
* and the error callback.
1740817408
*/
1740917409
typedef struct {
17410+
/** The parser that we are parsing the regular expression for. */
1741017411
pm_parser_t *parser;
17412+
17413+
/** The start of the regular expression. */
1741117414
const uint8_t *start;
17415+
17416+
/** The end of the regular expression. */
1741217417
const uint8_t *end;
17418+
17419+
/**
17420+
* Whether or not the source of the regular expression is shared. This
17421+
* impacts the location of error messages, because if it is shared then we
17422+
* can use the location directly and if it is not, then we use the bounds of
17423+
* the regular expression itself.
17424+
*/
1741317425
bool shared;
1741417426
} parse_regular_expression_error_data_t;
1741517427

@@ -20073,11 +20085,24 @@ parse_call_operator_write(pm_parser_t *parser, pm_call_node_t *call_node, const
2007320085
* and the named capture callback.
2007420086
*/
2007520087
typedef struct {
20088+
/** The parser that is parsing the regular expression. */
2007620089
pm_parser_t *parser;
20077-
const pm_string_t *content;
20090+
20091+
/** The call node wrapping the regular expression node. */
2007820092
pm_call_node_t *call;
20093+
20094+
/** The match write node that is being created. */
2007920095
pm_match_write_node_t *match;
20096+
20097+
/** The list of names that have been parsed. */
2008020098
pm_constant_id_list_t names;
20099+
20100+
/**
20101+
* Whether the content of the regular expression is shared. This impacts
20102+
* whether or not we used owned constants or shared constants in the
20103+
* constant pool for the names of the captures.
20104+
*/
20105+
bool shared;
2008120106
} parse_regular_expression_named_capture_data_t;
2008220107

2008320108
/**
@@ -20089,7 +20114,6 @@ parse_regular_expression_named_capture(const pm_string_t *capture, void *data) {
2008920114
parse_regular_expression_named_capture_data_t *callback_data = (parse_regular_expression_named_capture_data_t *) data;
2009020115

2009120116
pm_parser_t *parser = callback_data->parser;
20092-
const pm_string_t *content = callback_data->content;
2009320117
pm_call_node_t *call = callback_data->call;
2009420118
pm_constant_id_list_t *names = &callback_data->names;
2009520119

@@ -20103,15 +20127,15 @@ parse_regular_expression_named_capture(const pm_string_t *capture, void *data) {
2010320127
// not add it to the local table.
2010420128
if (!pm_slice_is_valid_local(parser, source, source + length)) return;
2010520129

20106-
if (content->type == PM_STRING_SHARED) {
20130+
if (callback_data->shared) {
2010720131
// If the unescaped string is a slice of the source, then we can
2010820132
// copy the names directly. The pointers will line up.
2010920133
location = (pm_location_t) { .start = source, .end = source + length };
2011020134
name = pm_parser_constant_id_location(parser, location.start, location.end);
2011120135
} else {
2011220136
// Otherwise, the name is a slice of the malloc-ed owned string,
2011320137
// in which case we need to copy it out into a new string.
20114-
location = call->receiver->location;
20138+
location = (pm_location_t) { .start = call->receiver->location.start, .end = call->receiver->location.end };
2011520139

2011620140
void *memory = xmalloc(length);
2011720141
if (memory == NULL) abort();
@@ -20157,9 +20181,9 @@ static pm_node_t *
2015720181
parse_regular_expression_named_captures(pm_parser_t *parser, const pm_string_t *content, pm_call_node_t *call) {
2015820182
parse_regular_expression_named_capture_data_t callback_data = {
2015920183
.parser = parser,
20160-
.content = content,
2016120184
.call = call,
20162-
.names = { 0 }
20185+
.names = { 0 },
20186+
.shared = content->type == PM_STRING_SHARED
2016320187
};
2016420188

2016520189
parse_regular_expression_error_data_t error_data = {

0 commit comments

Comments
 (0)