|
REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
|
real::compat::re2 — RE2's reading of the syntax REAL reads as Python's, rewritten into REAL's.
More...
#include <real/version.hpp>#include <algorithm>#include <bitset>#include <cstdint>#include <cstdio>#include <string>#include <string_view>#include <vector>#include <real/unicode/unicode_fold.hpp>#include <real/unicode/utf8.hpp>Namespaces | |
| namespace | real |
| REAL's public API: real::regex, real::static_regex, real::flags and the match/iterator types built on them. | |
| namespace | real::compat |
Drop-in replacements for <regex>, backed by REAL's linear-time engine where it can serve the pattern and by std::regex otherwise, never by a silent divergence. | |
| namespace | real::compat::re2 |
| Drop-in replacement for RE2's API surface, on REAL's engine. | |
Typedefs | |
| using | real::compat::re2::detail::ascii_set = std::bitset< 0x80 > |
| An ASCII set, one bit per byte below 0x80. | |
Functions | |
| bool | real::compat::re2::detail::re2_ascii_set (std::string_view name, ascii_set &set) |
| The ASCII set a shorthand letter or a POSIX class name stands for, as RE2 defines it. | |
| void | real::compat::re2::detail::append_code_point (std::string &out, std::uint32_t cp) |
Appends cp as a class member REAL reads in any position: \x{...}. | |
| void | real::compat::re2::detail::append_set (std::string &out, const ascii_set &set) |
Appends the members of set as class ranges. | |
| void | real::compat::re2::detail::append_complement (std::string &out, const ascii_set &set, bool icase) |
Appends, as class ranges, every scalar value outside set and, under icase, outside the case partners of its members: the class member RE2 reads for \W or [:^alpha:]. | |
| std::size_t | real::compat::re2::detail::next_character_length (std::string_view text, std::size_t pos) |
The length of the character at pos: its UTF-8 sequence when whole, else one byte (RE2 steps over an invalid byte alone). One past the end of text, one. | |
| std::string | real::compat::re2::detail::translate_flavor (std::string_view pattern, bool icase) |
Rewrites pattern from RE2's flavor into REAL's: ASCII shorthands and word boundaries, and the POSIX classes, the rest unchanged. Malformed text is copied as it is, for REAL to reject. | |
real::compat::re2 — RE2's reading of the syntax REAL reads as Python's, rewritten into REAL's.
RE2's \w \d \s are ASCII, its \b \B read ASCII word characters, and it reads the POSIX classes ([[:alpha:]]) inside a bracket. Under case folding RE2 folds a class member before negating it, the member's own negation included: (?i)[\W] leaves out k and the Kelvin sign alike. The rewrite gives REAL the same sets as written members, which REAL folds as RE2 does.
|
inline |
Appends cp as a class member REAL reads in any position: \x{...}.
| [in,out] | out | The class text. |
| [in] | cp | The code point. |
|
inline |
Appends, as class ranges, every scalar value outside set and, under icase, outside the case partners of its members: the class member RE2 reads for \W or [:^alpha:].
| [in,out] | out | The class text. |
| [in] | set | The set being negated. |
| [in] | icase | Whether the member is folded before it is negated. |
|
inline |
Appends the members of set as class ranges.
| [in,out] | out | The class text. |
| [in] | set | The set. |
|
inline |
The length of the character at pos: its UTF-8 sequence when whole, else one byte (RE2 steps over an invalid byte alone). One past the end of text, one.
| [in] | text | The text. |
| [in] | pos | A position in text, or its end. |
pos.
|
inline |
The ASCII set a shorthand letter or a POSIX class name stands for, as RE2 defines it.
| [in] | name | A shorthand letter (w, d, s) or a POSIX class name (alpha, word, ...). |
| [out] | set | Receives the set. |
false for a name RE2 does not define.
|
inline |
Rewrites pattern from RE2's flavor into REAL's: ASCII shorthands and word boundaries, and the POSIX classes, the rest unchanged. Malformed text is copied as it is, for REAL to reject.
| [in] | pattern | The pattern as RE2 reads it. |
| [in] | icase | Whether the pattern starts case-insensitive (Options::case_sensitive false). |