Ruby 4.1.0dev (2026-10-23 revision cc3776ba11cfcd1ff45a20ad82cb5200aaceb7b0)
regexp.h
1#ifndef PRISM_INTERNAL_REGEXP_H
2#define PRISM_INTERNAL_REGEXP_H
3
4#include "prism/ast.h"
5#include "prism/parser.h"
6
7/*
8 * Callback invoked by pm_regexp_parse() for each named capture group found.
9 * The data pointer is whatever the caller passed in alongside the callback; the
10 * regexp parser passes it through without inspecting it.
11 */
12typedef void (*pm_regexp_name_callback_t)(pm_parser_t *parser, const pm_string_t *name, void *data);
13
14/*
15 * Parse a regular expression, validate its encoding, and optionally extract
16 * named capture groups. Returns the encoding flags to set on the node.
17 */
18PRISM_EXPORTED_FUNCTION pm_node_flags_t pm_regexp_parse(pm_parser_t *parser, pm_regular_expression_node_t *node, pm_regexp_name_callback_t name_callback, void *name_data);
19
20/*
21 * Parse an interpolated regular expression for named capture groups only.
22 * No encoding validation is performed.
23 */
24void pm_regexp_parse_named_captures(pm_parser_t *parser, const uint8_t *source, size_t size, bool extended_mode, pm_regexp_name_callback_t name_callback, void *name_data);
25
26#endif
#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Definition exported.h:20
The parser used to parse Ruby source.
RegularExpressionNode.
Definition ast.h:7003
A view of a sequence of bytes.
Definition stringy.h:23