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

NameTypeDescription
_programNfaProgram
impl(NfaCompiler, ...)
new : (NfaCompiler) fn() -> NfaCompiler

Returns: NfaCompiler

_emit : (NfaCompiler) fn(self : NfaCompiler, instr : Instr) -> usize

Parameters

NameTypeNotes
selfNfaCompiler
instrInstr

Returns: usize

_current_pc : (NfaCompiler) fn(self : NfaCompiler) -> usize

Parameters

NameTypeNotes
selfNfaCompiler

Returns: usize

_add_class : (NfaCompiler) fn(self : NfaCompiler, ranges : <struct:struct_yo_id_62027>, negated : bool) -> usize

Parameters

NameTypeNotes
selfNfaCompiler
ranges<struct:struct_yo_id_62027>
negatedbool

Returns: usize

impl(NfaCompiler, ...)
_compile_node : (NfaCompiler) fn(self : NfaCompiler, node : RegexNode) -> unit

Parameters

NameTypeNotes
selfNfaCompiler
nodeRegexNode

Returns: unit

impl(NfaCompiler, ...)
_extract_literal_prefix : (NfaCompiler) fn(self : NfaCompiler) -> unit

Parameters

NameTypeNotes
selfNfaCompiler

Returns: unit

impl(NfaCompiler, ...)
compile : (NfaCompiler) fn(self : NfaCompiler, root : RegexNode, n_groups : usize, group_names : <struct:struct_yo_id_62215>) -> NfaProgram

Parameters

NameTypeNotes
selfNfaCompiler
rootRegexNode
n_groupsusize
group_names<struct:struct_yo_id_62215>

Returns: NfaProgram

NfaProgram object
NfaProgram

Fields

NameTypeDescription
instructions<struct:struct_yo_id_62205>
classes<struct:struct_yo_id_62210>
n_groupsusize
group_names<struct:struct_yo_id_62215>
literal_prefix<struct:struct_yo_id_3539>
Instr struct
Instr

Fields

NameTypeDescription
kindInstrKind
codepointu32
class_idxusize
target_ausize
target_busize
targetusize
slotusize
impl(Instr, ...)
char_instr : (Instr) fn(cp : u32) -> Instr

Parameters

NameTypeNotes
cpu32

Returns: Instr

any_char_instr : (Instr) fn() -> Instr

Returns: Instr

char_class_instr : (Instr) fn(idx : usize) -> Instr

Parameters

NameTypeNotes
idxusize

Returns: Instr

split_instr : (Instr) fn(a : usize, b : usize) -> Instr

Parameters

NameTypeNotes
ausize
busize

Returns: Instr

jump_instr : (Instr) fn(t : usize) -> Instr

Parameters

NameTypeNotes
tusize

Returns: Instr

save_instr : (Instr) fn(s : usize) -> Instr

Parameters

NameTypeNotes
susize

Returns: Instr

match_instr : (Instr) fn() -> Instr

Returns: Instr

assert_start_instr : (Instr) fn() -> Instr

Returns: Instr

assert_end_instr : (Instr) fn() -> Instr

Returns: Instr

assert_word_boundary_instr : (Instr) fn() -> Instr

Returns: Instr

assert_non_word_boundary_instr : (Instr) fn() -> Instr

Returns: Instr

backref_instr : (Instr) fn(group_idx : usize) -> Instr

Parameters

NameTypeNotes
group_idxusize

Returns: Instr

lookahead_instr : (Instr) fn(sub_start : usize, sub_end : usize, positive : bool) -> Instr

Parameters

NameTypeNotes
sub_startusize
sub_endusize
positivebool

Returns: Instr

lookbehind_instr : (Instr) fn(sub_start : usize, sub_end : usize, positive : bool) -> Instr

Parameters

NameTypeNotes
sub_startusize
sub_endusize
positivebool

Returns: Instr

InstrKind enum
InstrKind

NFA instruction types.

Variants

VariantFieldsDescription
Char
CharClass
AnyChar
Split
Jump
Save
Match
AssertStart
AssertEnd
AssertWordBoundary
AssertNonWordBoundary
Backref
Lookahead
Lookbehind
ClassEntry struct
ClassEntry

Fields

NameTypeDescription
ranges<struct:struct_yo_id_62027>
negatedbool
GroupNameEntry

Fields

NameTypeDescription
nameString
indexusize