mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
50 lines
2.2 KiB
C
50 lines
2.2 KiB
C
#ifndef EXPERIMENTAL_REGEX_BRIDGING
|
|
#define EXPERIMENTAL_REGEX_BRIDGING
|
|
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/// Attempt to lex a regex literal string. Takes the following arguments:
|
|
///
|
|
/// - CurPtrPtr: A pointer to the current pointer of lexer, which should be the
|
|
/// start of the literal. This will be advanced to the point at
|
|
/// which the lexer should resume, or will remain the same if this
|
|
/// is not a regex literal.
|
|
/// - BufferEnd: A pointer to the end of the buffer, which should not be lexed
|
|
/// past.
|
|
/// - ErrorOut: If an error is encountered, this will be set to the error
|
|
/// string.
|
|
///
|
|
/// Returns: A bool indicating whether lexing was completely erroneous, and
|
|
/// cannot be recovered from, or false if there either was no error,
|
|
/// or there was a recoverable error.
|
|
typedef bool (* RegexLiteralLexingFn)(/*CurPtrPtr*/ const char **,
|
|
/*BufferEnd*/ const char *,
|
|
/*ErrorOut*/ const char **);
|
|
void Parser_registerRegexLiteralLexingFn(RegexLiteralLexingFn fn);
|
|
|
|
/// Parse a regex literal string. Takes the following arguments:
|
|
///
|
|
/// - InputPtr: A null-terminated C string of the regex literal.
|
|
/// - ErrorOut: A buffer accepting an error string upon error.
|
|
/// - VersionOut: A buffer accepting a regex literal format version.
|
|
/// - CaptureStructureOut: A buffer accepting a byte sequence representing the
|
|
/// capture structure of the literal.
|
|
/// - CaptureStructureSize: The size of the capture structure buffer. Must be
|
|
/// greater than or equal to `strlen(InputPtr) + 3`.
|
|
typedef void(* RegexLiteralParsingFn)(/*InputPtr*/ const char *,
|
|
/*ErrorOut*/ const char **,
|
|
/*VersionOut*/ unsigned *,
|
|
/*CaptureStructureOut*/ void *,
|
|
/*CaptureStructureSize*/ unsigned);
|
|
void Parser_registerRegexLiteralParsingFn(RegexLiteralParsingFn fn);
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif // EXPERIMENTAL_REGEX_BRIDGING
|