REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real Namespace Reference

Namespaces

namespace  compat
 
namespace  detail
 

Classes

class  basic_match_iterator
 Forward iterator over the non-overlapping matches in a text. More...
 
class  basic_match_range
 A range of matches, returned by find_iter() and usable in range-for. More...
 
class  basic_match_result
 The result of a match attempt: success, spans and captures. More...
 
class  basic_regex
 A compiled regular expression, parameterized on its storage policy. More...
 
class  dfa
 A maximal-munch DFA over an ordered set of patterns. More...
 
class  dfa_error
 Thrown when a pattern cannot be represented as a DFA. More...
 
struct  dfa_match
 The outcome of dfa::match — which rule won, and how many bytes it spans. More...
 
struct  fixed_string
 A fixed-size string usable as a non-type template parameter. More...
 
class  regex_error
 

Typedefs

using match_result = basic_match_result< std::vector< std::size_t > >
 The result type of the default, runtime-compiled real::regex.
 
using regex = basic_regex< detail::dynamic_storage >
 The runtime-compiled regex type — the primary entry point.
 
template<fixed_string Pattern, flags F = flags::none>
using static_regex = basic_regex< detail::static_storage< Pattern, F > >
 A fully compile-time regex.
 

Enumerations

enum class  flags : std::uint8_t {
  none = 0 , icase = 1 , multiline = 2 , dotall = 4 ,
  bytes = 8 , verbose = 16 , ecma = 32 , ascii = 64 ,
  dollar_endonly = 128
}
 Compilation flags, mirroring Python's re.I, re.M and re.S. More...
 
enum class  match_semantics : std::uint8_t { first = 0 , longest = 1 }
 Which match a search returns among those starting at the leftmost position (an experimental, opt-in, off-by-default engine mode — the default is unchanged). More...
 
enum class  error_kind : std::uint8_t { syntax , unsupported }
 Exception thrown for an invalid pattern (or one exceeding a limit). More...
 

Functions

constexpr flags operator| (flags lhs, flags rhs)
 Bitwise-OR of two flag sets.
 
constexpr flags operator& (flags lhs, flags rhs)
 Bitwise-AND of two flag sets.
 
constexpr bool has_flag (flags value, flags flag)
 Tests whether flag is set in value.
 

Variables

constexpr std::size_t npos {std::numeric_limits<std::size_t>::max()}
 Sentinel for "no position" / unset capture slot (akin to std::string::npos).
 

Typedef Documentation

◆ match_result

using real::match_result = typedef basic_match_result<std::vector<std::size_t> >

The result type of the default, runtime-compiled real::regex.

Definition at line 247 of file real.hpp.

◆ regex

The runtime-compiled regex type — the primary entry point.

Definition at line 1058 of file real.hpp.

◆ static_regex

template<fixed_string Pattern, flags F = flags::none>
using real::static_regex = typedef basic_regex<detail::static_storage<Pattern, F> >

A fully compile-time regex.

The pattern is parsed, compiled and exactly sized at compile time; matching allocates nothing and also works in a constexpr context. An invalid pattern is a compile error.

Template Parameters
PatternThe pattern, as a fixed_string literal.
FCompilation flags.

Definition at line 1071 of file real.hpp.

Enumeration Type Documentation

◆ error_kind

enum class real::error_kind : std::uint8_t
strong

Exception thrown for an invalid pattern (or one exceeding a limit).

In a constexpr context (static_regex), reaching the throw is a compile-time error, with the message appearing in the diagnostic trace.

Whether a rejected pattern is malformed (syntax) or well-formed but beyond REAL's linear engine (unsupported: a backreference, \p{…}, a nested/unbounded lookaround). The distinction is a stable, machine-readable classification the C ABI exposes so a binding never has to grep what().

Enumerator
syntax 
unsupported 

Definition at line 107 of file program.hpp.

◆ flags

enum class real::flags : std::uint8_t
strong

Compilation flags, mirroring Python's re.I, re.M and re.S.

Combinable with operator|. Case folding is ASCII-only, consistent with the library's character-class semantics.

Enumerator
none 

No flags.

icase 

Case-insensitive (ASCII).

multiline 

^ and $ also match at line boundaries.

dotall 

. also matches \n.

bytes 

Binary mode: . and [^…] match raw bytes, not codepoints.

verbose 

Verbose mode (re.X): ignore unescaped whitespace and # comments outside classes.

ecma 

ECMAScript compatibility: $ (no multiline) matches only at the very end (not before a final \n, the Python default), AND . (no dotall) also excludes \r (ECMAScript excludes \n and \r; the multi-byte U+2028/U+2029 have no byte-level effect).

ascii 

ASCII mode (re.A): \d \w \s \b stay ASCII and icase folds ASCII only, even in text mode. ., explicit classes and UTF-8 literals stay code-point-aware.

dollar_endonly 

$ (no multiline) matches only at the very end of the text, never before a final \n — the Rust/\z semantics. Unlike flags::ecma this touches $ ONLY, leaving . at the Python default. Used by the Rust binding for drop-in parity.

Definition at line 41 of file program.hpp.

◆ match_semantics

enum class real::match_semantics : std::uint8_t
strong

Which match a search returns among those starting at the leftmost position (an experimental, opt-in, off-by-default engine mode — the default is unchanged).

Enumerator
first 

Leftmost-first (Perl / Python re / the crate): source-order thread priority decides. Default.

longest 

Leftmost-longest (POSIX / RE2 set_longest_match): the longest overall match wins the bounds.

Definition at line 56 of file program.hpp.

Function Documentation

◆ has_flag()

constexpr bool real::has_flag ( flags  value,
flags  flag 
)
constexpr

Tests whether flag is set in value.

Parameters
[in]valueThe flag set to query.
[in]flagThe single flag to look for.
Returns
true if flag is present in value.

Definition at line 92 of file program.hpp.

◆ operator&()

constexpr flags real::operator& ( flags  lhs,
flags  rhs 
)
constexpr

Bitwise-AND of two flag sets.

Parameters
[in]lhsFirst flag set.
[in]rhsSecond flag set.
Returns
The intersection of lhs and rhs.

Definition at line 80 of file program.hpp.

◆ operator|()

constexpr flags real::operator| ( flags  lhs,
flags  rhs 
)
constexpr

Bitwise-OR of two flag sets.

Parameters
[in]lhsFirst flag set.
[in]rhsSecond flag set.
Returns
The union of lhs and rhs.

Definition at line 68 of file program.hpp.

Variable Documentation

◆ npos

constexpr std::size_t real::npos {std::numeric_limits<std::size_t>::max()}
inlineconstexpr

Sentinel for "no position" / unset capture slot (akin to std::string::npos).

Definition at line 33 of file program.hpp.