[ruby/psych] Add support for ruby 3.2 Data objects
[ruby.git] / prism / regexp.h
blobc0b3163e93b649e013840973bdb3f4209dea6413
1 /**
2 * @file regexp.h
4 * A regular expression parser.
5 */
6 #ifndef PRISM_REGEXP_H
7 #define PRISM_REGEXP_H
9 #include "prism/defines.h"
10 #include "prism/parser.h"
11 #include "prism/encoding.h"
12 #include "prism/util/pm_memchr.h"
13 #include "prism/util/pm_string.h"
15 #include <stdbool.h>
16 #include <stddef.h>
17 #include <string.h>
19 /**
20 * This callback is called when a named capture group is found.
22 typedef void (*pm_regexp_name_callback_t)(const pm_string_t *name, void *data);
24 /**
25 * This callback is called when a parse error is found.
27 typedef void (*pm_regexp_error_callback_t)(const uint8_t *start, const uint8_t *end, const char *message, void *data);
29 /**
30 * Parse a regular expression.
32 * @param parser The parser that is currently being used.
33 * @param source The source code to parse.
34 * @param size The size of the source code.
35 * @param extended_mode Whether to parse the regular expression in extended mode.
36 * @param name_callback The optional callback to call when a named capture group is found.
37 * @param name_data The optional data to pass to the name callback.
38 * @param error_callback The callback to call when a parse error is found.
39 * @param error_data The data to pass to the error callback.
41 PRISM_EXPORTED_FUNCTION void pm_regexp_parse(pm_parser_t *parser, const uint8_t *source, size_t size, bool extended_mode, pm_regexp_name_callback_t name_callback, void *name_data, pm_regexp_error_callback_t error_callback, void *error_data);
43 #endif