diff options
author | Kevin Newton <[email protected]> | 2024-06-04 12:05:48 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-06-05 14:40:03 -0400 |
commit | ad438623e8f4e90b7d6567c6c552be89d080dcca (patch) | |
tree | 49919529999290e3e56b47afb37c07b3d6bfeeae /prism/regexp.h | |
parent | aa61d4237dad54e01c00f8cef4ba7f7cdffb8a80 (diff) |
[ruby/prism] Switch regexp parsing to use a callback from named capture groups
https://github.com/ruby/prism/commit/29d80e486e
Diffstat (limited to 'prism/regexp.h')
-rw-r--r-- | prism/regexp.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/prism/regexp.h b/prism/regexp.h index c5ceab11f9..ca5185d2fd 100644 --- a/prism/regexp.h +++ b/prism/regexp.h @@ -18,16 +18,21 @@ #include <string.h> /** - * Parse a regular expression and extract the names of all of the named capture - * groups. + * This callback is called when a named capture group is found. + */ +typedef void (*pm_regexp_name_callback_t)(const pm_string_t *name, void *data); + +/** + * Parse a regular expression. * * @param source The source code to parse. * @param size The size of the source code. - * @param named_captures The list to add the names of the named capture groups. * @param encoding_changed Whether or not the encoding changed from the default. * @param encoding The encoding of the source code. + * @param name_callback The callback to call when a named capture group is found. + * @param name_data The data to pass to the name callback. * @return Whether or not the parsing was successful. */ -PRISM_EXPORTED_FUNCTION bool pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding); +PRISM_EXPORTED_FUNCTION bool pm_regexp_parse(const uint8_t *source, size_t size, bool encoding_changed, const pm_encoding_t *encoding, pm_regexp_name_callback_t name_callback, void *name_data); #endif |