|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
Pattern text → AST, via a constexpr recursive-descent parser. More...
#include "real/version.hpp"#include <array>#include <algorithm>#include <cstdint>#include <span>#include <string_view>#include <vector>#include "real/core/charclass.hpp"#include "real/core/config.hpp"#include "real/core/program.hpp"#include "real/unicode/unicode_binprop.hpp"#include "real/unicode/unicode_fold.hpp"#include "real/unicode/unicode_property.hpp"#include "real/unicode/unicode_props.hpp"#include "real/unicode/unicode_script.hpp"#include "real/unicode/unicode_scx.hpp"#include "real/unicode/utf8.hpp"Classes | |
| struct | real::detail::ast_node |
| One AST node. Active fields depend on kind (noted per field). More... | |
| struct | real::detail::class_def |
| A parsed character class: its ASCII bitmap plus any non-ASCII code-point ranges. Bundling the two (rather than parallel side tables) makes them impossible to desynchronize. More... | |
| struct | real::detail::ast |
| A parsed pattern: the node pool plus side tables. More... | |
| struct | real::detail::digit_escape_result |
| Result of decode_digit_escape. More... | |
| class | real::detail::parser |
| Recursive-descent parser: a pattern string in, an ast out. More... | |
| struct | real::detail::parser::shorthand_spec |
The classification of a \d \D \w \W \s \S shorthand: its ASCII bitmap, its Unicode range table, and whether it is the negated (uppercase) form. More... | |
| struct | real::detail::parser::loose_buf |
A loose-match key (lowercase, no _/-/space; UAX44-LM3-ish) built into a fixed buffer, so no heap or <string> is needed at parse time. A name longer than the buffer simply fails to match. More... | |
| struct | real::detail::parser::property_table_result |
The result of parse_property_table — the property's code-point ranges, plus whether a leading \p{^...} caret was stripped (RE2/Perl negation-by-caret, e.g. \p{^L} == \P{L}). caret is XORed into the caller's own negation flag so the caret composes with \P / [^...] instead of overriding them. More... | |
| struct | real::detail::parser::quoted_span |
What parse_quoted_span emitted: a bare pre-chained all-but-last prefix (head..head_tail, -1 when the span has fewer than two characters) plus the span's final atom last (-1 when the span is empty) — the caller's quantifier target. More... | |
Namespaces | |
| namespace | real |
| REAL's public API: real::regex, real::static_regex, real::flags and the match/iterator types built on them. | |
| namespace | real::detail |
| DFA construction internals: subset construction over a flattened NFA. Not a stable API. | |
Enumerations | |
| enum class | real::detail::node_kind : std::uint8_t { real::detail::empty , real::detail::byte , real::detail::klass , real::detail::any , real::detail::concat , real::detail::repeat , real::detail::alternation , real::detail::group , real::detail::anchor , real::detail::lookaround } |
| Kind of an AST node; selects which fields of real::detail::ast_node are meaningful. More... | |
| enum class | real::detail::anchor_kind : std::uint8_t { real::detail::caret , real::detail::dollar , real::detail::text_start , real::detail::text_end , real::detail::word_boundary , real::detail::not_word_boundary , real::detail::word_start , real::detail::word_end } |
The specific zero-width assertion of an anchor node (see node_kind::anchor). More... | |
| enum class | real::detail::digit_escape_kind : std::uint8_t { real::detail::octal , real::detail::group_ref , real::detail::octal_overflow } |
What a \<digit> escape decoded to (see decode_digit_escape()). More... | |
Functions | |
| constexpr std::vector< code_range > | real::detail::coalesce_ranges (std::vector< code_range > ranges) |
Sorts ranges and merges overlapping / adjacent ones into a minimal, sorted set (the same set of code points, the fewest ranges). Used to keep folded / property classes compact. | |
| constexpr std::vector< code_range > | real::detail::complement_code_ranges (std::vector< code_range > ranges) |
Complements a set of code-point ranges within [0x80, 0x10FFFF] (used by negated classes and by an in-class \W/\D/\S). Input may be unsorted/overlapping; the gaps come sorted. | |
| constexpr std::uint32_t | real::detail::single_codepoint_atom (const ast &tree, std::int32_t index) |
| The code point a node spells, when it is exactly one non-ASCII literal character. | |
| constexpr digit_escape_result | real::detail::decode_digit_escape (std::string_view text, std::size_t first) |
Decodes a \<digit> escape per CPython's exact rule (shared by the pattern parser and the replacement-template parser, so the two never drift). | |
| constexpr ast | real::detail::parse (std::string_view pattern, flags initial_flags=flags::none) |
Parses pattern into an ast (convenience over parser). | |
Variables | |
| constexpr std::uint32_t | real::detail::not_a_single_codepoint {0xFFFFFFFFU} |
| Returned by single_codepoint_atom when the node is not one code point's bytes. | |
Pattern text → AST, via a constexpr recursive-descent parser.
The parser builds nodes in an index-based pool (no pointers, so it is constexpr-friendly). It accepts only the syntax the rest of the pipeline implements; everything else is a real::regex_error.
In code-point mode (the default), a character class carries specific non-ASCII code-point members and ranges ([é], [à-ÿ], [^é]) alongside its ASCII bitmap; they compile to the canonical UTF-8-ranges automaton, so a class matches exactly those code points (and never an overlong / surrogate encoding). . and an ASCII-only negated class ([^x]) still match any non-ASCII code point. In bytes mode a non-ASCII class member is rejected (raw byte semantics). Every construct consumes whole code points, so match boundaries never split a sequence.