|
| constexpr void | emit_codepoint_class (dynamic_program &prog, const char_class &ascii) const |
| | Emits "one codepoint matching \p ascii, or any non-ASCII codepoint".
|
| |
| constexpr void | emit_byte_sequences (dynamic_program &prog, const std::vector< std::vector< char_class > > &branches) const |
| | Emits an alternation of byte-range sequences (branches) as split/jump — the general form of emit_codepoint_class. Each branch is a chain of klass steps; the leftmost matching branch wins. Used for a character class carrying specific code-point ranges.
|
| |
| constexpr void | emit_class_codepoints (dynamic_program &prog, const char_class &ascii, const std::vector< code_range > &ranges) const |
| | Emits a code-point class: the ASCII bitmap (one byte, if any) OR the canonical UTF-8 byte sequences of each code-point range. This is the specific-code-point generalization of emit_codepoint_class (whose [U+0080, U+10FFFF] "any non-ASCII" is one case).
|
| |
| constexpr class_def | effective_class (const ast_node &node) const |
| | The class a node_kind::klass node effectively accepts, after negation, icase folding and the bytes/code-point split. This is the ONE source of truth consumed by both emit_node and l_max_bytes, so what is emitted and its measured width can never disagree. Positive: as written. Negated: the ASCII complement plus, in code-point mode, the code-point complement over [U+0080, U+10FFFF] minus surrogates.
|
| |
| constexpr void | emit_node (dynamic_program &prog, std::int32_t index, bool capture_free=false) const |
| | Emits the bytecode for the AST node at index (recursively).
|
| |
| constexpr assert_kind | assert_kind_for (anchor_kind anchor, flags node_flags) const |
| | Maps an AST anchor_kind to the runtime assert_kind.
|
| |
| constexpr void | emit_alternation (dynamic_program &prog, const ast_node &node, bool capture_free) const |
| | Emits an alternation: branches chained with leftmost-preferred splits.
|
| |
| constexpr void | emit_repeat (dynamic_program &prog, const ast_node &node, bool capture_free) const |
| | Emits a quantifier (Thompson construction).
|
| |
| constexpr void | emit_lookaround (dynamic_program &prog, const ast_node &node, bool capture_free) const |
| | Emits a bounded lookaround: an assert_lookaround whose sub-program is a capture-free region the main flow jumps over.
|
| |
| constexpr std::int32_t | l_max_bytes (std::int32_t index) const |
| | Upper bound, in bytes, on what the sub-AST at index can consume; -1 if unbounded (a *, + or {n,} repeat) or if it nests a lookaround.
|
| |
|
| static constexpr std::int32_t | here (const dynamic_program &prog) |
| | Returns the index of the next instruction.
|
| |
| static constexpr void | emit (dynamic_program &prog, instr instruction) |
| | Appends one instruction, enforcing the program-size cap.
|
| |
| static constexpr std::int32_t | emit_split (dynamic_program &prog) |
| | Emits a split with placeholder targets.
|
| |
| static constexpr std::int32_t | emit_jump (dynamic_program &prog) |
| | Emits a jump with a placeholder target.
|
| |
| static constexpr void | patch_primary (dynamic_program &prog, std::int32_t pc, std::int32_t target) |
| | Sets the primary branch target of the instruction at pc.
|
| |
| static constexpr void | patch_secondary (dynamic_program &prog, std::int32_t pc, std::int32_t target) |
| | Sets the secondary branch target of the split at pc.
|
| |
| static constexpr void | emit_klass (dynamic_program &prog, const char_class &klass) |
| | Emits a klass instruction, interning klass.
|
| |
| static constexpr void | emit_klass_cp (dynamic_program &prog, const class_def &cd) |
| | Emits a match-time code-point predicate for a Unicode shorthand (\w \d \s and their negations) in text mode: a klass_cp over the interned code-point class, followed by a three-instruction continuation chain (klass utf8_cont ×3). At match time klass_cp decodes one code point and, on membership, enters the chain at a computed skip so the remaining continuation bytes are walked one per step — see pike.hpp. The class is the already-effective set (the fold and any external negation were materialised by effective_class), so membership is a plain positive test.
|
| |
Compiles an ast into a dynamic_program (NFA bytecode).
Definition at line 108 of file compiler.hpp.
| constexpr class_def real::detail::compiler::effective_class |
( |
const ast_node & |
node | ) |
const |
|
inlineconstexprprivate |
The class a node_kind::klass node effectively accepts, after negation, icase folding and the bytes/code-point split. This is the ONE source of truth consumed by both emit_node and l_max_bytes, so what is emitted and its measured width can never disagree. Positive: as written. Negated: the ASCII complement plus, in code-point mode, the code-point complement over [U+0080, U+10FFFF] minus surrogates.
Definition at line 451 of file compiler.hpp.
|
|
inlinestaticconstexprprivate |
Appends one instruction, enforcing the program-size cap.
The check lives inside emit so it fires during a large unroll loop, before the vector grows to the full bad size — this is the central defense (max_program_size) against the DoS where tiny nested bounded quantifiers expand to hundreds of millions of instructions. It is constexpr-friendly: exceeding the cap fails compilation for a static_regex, or throws at run time.
- Parameters
-
| [in,out] | prog | The program being built. |
| [in] | instruction | The instruction to append. |
- Exceptions
-
Definition at line 183 of file compiler.hpp.
Emits "one codepoint matching \p ascii, or any non-ASCII codepoint".
Expands to the byte-level alternation ascii | lead2 cont | lead3 cont cont | lead4 cont cont cont, so the engine steps one byte at a time while still consuming whole codepoints. The UTF-8 byte sets come from charclass.hpp, shared with the prefilter that recognizes this exact shape.
- Parameters
-
| [in,out] | prog | The program being built. |
| [in] | ascii | The accepted ASCII bytes (the non-ASCII branches are always included). |
Definition at line 338 of file compiler.hpp.
| constexpr std::int32_t real::detail::compiler::l_max_bytes |
( |
std::int32_t |
index | ) |
const |
|
inlineconstexprprivate |
Upper bound, in bytes, on what the sub-AST at index can consume; -1 if unbounded (a *, + or {n,} repeat) or if it nests a lookaround.
Codepoint-consuming shapes (., a negated class outside bytes mode) count as one codepoint = up to 4 bytes (A1); a literal byte or an ASCII class is one byte.
- Parameters
-
| [in] | index | Index of the sub-AST node. |
- Returns
- The byte upper bound, or -1 when not statically bounded.
Definition at line 807 of file compiler.hpp.