Module regex/compiler
regex/compiler
NFA compiler — compiles a RegexNode AST into a flat list of NFA instructions
using Thompson's construction algorithm.
Types
NfaCompiler
object
NfaCompiler
Fields
| Name | Type | Description |
|---|---|---|
_program | NfaProgram |
impl(NfaCompiler, ...)
new : (NfaCompiler) fn() -> NfaCompilerReturns: NfaCompiler
_emit : (NfaCompiler) fn(self : NfaCompiler, instr : Instr) -> usize_current_pc : (NfaCompiler) fn(self : NfaCompiler) -> usize_add_class : (NfaCompiler) fn(self : NfaCompiler, ranges : ArrayList(CharRange), negated : bool) -> usizeimpl(NfaCompiler, ...)
_compile_node : (NfaCompiler) fn(self : NfaCompiler, node : RegexNode) -> unitimpl(NfaCompiler, ...)
_extract_literal_prefix : (NfaCompiler) fn(self : NfaCompiler) -> unitimpl(NfaCompiler, ...)
compile : (NfaCompiler) fn(self : NfaCompiler, root : RegexNode, n_groups : usize, group_names : ArrayList(GroupNameEntry)) -> NfaProgramParameters
| Name | Type | Notes |
|---|---|---|
self | NfaCompiler | |
root | RegexNode | |
n_groups | usize | |
group_names | ArrayList(GroupNameEntry) |
Returns: NfaProgram
NfaProgram
object
NfaProgram
Fields
| Name | Type | Description |
|---|---|---|
instructions | ArrayList(Instr) | |
classes | ArrayList(ClassEntry) | |
n_groups | usize | |
group_names | ArrayList(GroupNameEntry) | |
literal_prefix | ArrayList(u8) |
Instr
struct
Instr
Fields
| Name | Type | Description |
|---|---|---|
kind | InstrKind | |
codepoint | u32 | |
class_idx | usize | |
target_a | usize | |
target_b | usize | |
target | usize | |
slot | usize |
impl(Instr, ...)
char_instr : (Instr) fn(cp : u32) -> Instrany_char_instr : (Instr) fn() -> InstrReturns: Instr
char_class_instr : (Instr) fn(idx : usize) -> Instrsplit_instr : (Instr) fn(a : usize, b : usize) -> Instrjump_instr : (Instr) fn(t : usize) -> Instrsave_instr : (Instr) fn(s : usize) -> Instrmatch_instr : (Instr) fn() -> InstrReturns: Instr
assert_start_instr : (Instr) fn() -> InstrReturns: Instr
assert_end_instr : (Instr) fn() -> InstrReturns: Instr
assert_word_boundary_instr : (Instr) fn() -> InstrReturns: Instr
assert_non_word_boundary_instr : (Instr) fn() -> InstrReturns: Instr
backref_instr : (Instr) fn(group_idx : usize) -> Instrlookahead_instr : (Instr) fn(sub_start : usize, sub_end : usize, positive : bool) -> Instrlookbehind_instr : (Instr) fn(sub_start : usize, sub_end : usize, positive : bool) -> Instr
InstrKind
enum
InstrKind
NFA instruction types.
Variants
| Variant | Fields | Description |
|---|---|---|
Char | ||
CharClass | ||
AnyChar | ||
Split | ||
Jump | ||
Save | ||
Match | ||
AssertStart | ||
AssertEnd | ||
AssertWordBoundary | ||
AssertNonWordBoundary | ||
Backref | ||
Lookahead | ||
Lookbehind |
ClassEntry
struct
GroupNameEntry
struct