![]() |
Fun API Documentation 0.42.1
The programming language that makes you have fun!
|
PCRE2 helpers for Fun VM extension opcodes (conditional build). More...
#include <pcre2.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | PCRE2_CODE_UNIT_WIDTH 8 |
Functions | |
| static uint32_t | fun_pcre2_opts_from_flags (int flags) |
| Map Fun VM regex flags to PCRE2 compile options. | |
| static int | fun_pcre2_test (const char *pattern, const char *subject, int flags) |
| Test whether a pattern matches a subject at least once. | |
| static Value | fun_pcre2_match (const char *pattern, const char *subject, int flags) |
| Match a pattern once and return a structured result map. | |
| static Value | fun_pcre2_findall (const char *pattern, const char *subject, int flags) |
| Find all non-overlapping matches of a pattern in a subject. | |
PCRE2 helpers for Fun VM extension opcodes (conditional build).
This module centralizes the concrete PCRE2 implementation so VM opcodes in src/vm/pcre2/*.c only perform stack marshalling and delegate to these helpers. This mirrors the approach used by other extensions (e.g. SQLite, XML2) where the heavy lifting lives under src/extensions/ and the opcodes just call into small C helpers.
Build-time feature flag:
PCRE2 width configuration:
Flags mapping used by helpers/opcodes (bitmask in the VM):
Value and memory ownership:
Thread-safety:
Definition in file pcre2.c.
|
static |
Find all non-overlapping matches of a pattern in a subject.
Scans the subject from left to right and appends, for each non-overlapping match, a map with the same shape as fun_pcre2_match() to the result array. If the engine reports an empty match (start == end), the scan advances by a single code unit to prevent infinite loops.
On pattern compile failure or allocation error, returns an empty array.
| pattern | NUL-terminated regex pattern string. |
| subject | NUL-terminated subject string. |
| flags | VM bitmask translated by fun_pcre2_opts_from_flags(). |
|
static |
Match a pattern once and return a structured result map.
On success, returns a map with the following keys:
On no match, pattern compile failure, or memory allocation error, returns Nil.
| pattern | NUL-terminated regex pattern string. |
| subject | NUL-terminated subject string. |
| flags | VM bitmask translated by fun_pcre2_opts_from_flags(). |
|
static |
Map Fun VM regex flags to PCRE2 compile options.
The Fun VM passes a small integer bitmask controlling common regex behaviours. This function translates those bits into the corresponding PCRE2 compile options.
Bit mapping:
| flags | Bitmask provided by the VM. |
|
static |
Test whether a pattern matches a subject at least once.
Compiles the given pattern with options derived from the flags bitmask and runs pcre2_match() once starting at offset 0.
| pattern | NUL-terminated regex pattern string. |
| subject | NUL-terminated subject string. |
| flags | VM bitmask translated by fun_pcre2_opts_from_flags(). |