Expand description
Pattern matching engine for zshrs
Direct port from zsh/Src/pattern.c
This implements a bytecode-compiled pattern matching engine supporting:
- Basic wildcards: *, ?, […]
- Extended glob patterns: #, ##, ~, ^
- KSH glob patterns: ?(pat), *(pat), +(pat), !(pat), @(pat)
- Backreferences with parentheses
- Case-insensitive matching
- Approximate matching (error tolerance)
- Numeric ranges:
<n-m>
Structs§
- Glob
Flags - Globbing flags
- PatFlags
- Pattern flags
- PatMatcher
- Pattern matcher state
- PatProg
- Compiled pattern program
- Pattern
Scope - Pattern scope management - save disabled patterns
Enums§
Constants§
- COLON_
CLASSES - POSIX character class type names for
[:stuff:]
Functions§
- charnext
- Get next char (from pattern.c charnext) - Rust native char iteration
- charref
- Get char reference (from pattern.c charref) - Rust native char
- charrefinc
- Get char and advance (from pattern.c charrefinc) - Rust native char
- charsub
- Get previous char width (from pattern.c charsub) - Rust native char
- clear_
shiftstate - Clear multibyte shift state (from pattern.c clear_shiftstate) - no-op in Rust
- clearpatterndisables
- Clear pattern disables
- endpatternscope
- End a pattern scope (from pattern.c endpatternscope)
- freepatprog
- Free a compiled pattern (no-op in Rust, but provided for API compat)
- haswilds
- Check if string contains pattern characters (from pattern.c haswilds)
- mb_
patmatchindex - Multibyte pattern match index (from pattern.c mb_patmatchindex)
- mb_
patmatchrange - Multibyte pattern match range (from pattern.c mb_patmatchrange) - uses native char
- metacharinc
- Advance past metafied char (from pattern.c metacharinc) - no-op in Rust (native UTF-8)
- pat_
enables - Enable/disable pattern commands (from pattern.c pat_enables)
- patadd
- Add bytes to pattern buffer (from pattern.c patadd) - Rust uses
Vec<PatNode> - patallocstr
- Allocate pattern string buffer (from pattern.c patallocstr) - no-op in Rust
- patcompbranch
- Compile a pattern branch - implemented as PatCompiler::compile_branch_inner
- patcompcharsset
- Set up pattern compiler char sets (from pattern.c patcompcharsset) - no-op in Rust
- patcompile
- Compile a pattern string into a program
- patcompile_
opts - Compile with options
- patcompnot
- Compile negation pattern - implemented as PatCompiler handling of ^ and !()
- patcomppiece
- Compile a single pattern piece - implemented as PatCompiler::compile_piece
- patcompstart
- Initialize pattern compilation (from pattern.c patcompstart) - no-op in Rust
- patcompswitch
- Compile top-level pattern switch (alternation) - implemented as PatCompiler::compile_branch
- patgetglobflags
- Parse glob flags from (#…) syntax (from pattern.c patgetglobflags)
- patinsert
- Insert node at position (from pattern.c patinsert) - Rust uses Vec::insert
- patmatch
- Simple pattern match (compile and match in one call)
- patmatch_
captures - Match with captures - returns capture groups if matched
- patmatch_
opts - Pattern match with options
- patmatchindex
- Find index of character in range (from pattern.c patmatchindex)
- patmatchlen
- Get the length of the successful match (from pattern.c patmatchlen)
- patmatchrange
- Check if character matches a character range element (from pattern.c patmatchrange)
- patmungestring
- Prepare string for pattern matching (from pattern.c patmungestring) - identity in Rust
- patnode
- Add node to bytecode (from pattern.c patnode) - Rust uses
Vec<PatNode> - patoptail
- Set optional tail pointer (from pattern.c patoptail) - no-op in Rust AST model
- patrepeat
- Repeat match for the given pattern node (from pattern.c patrepeat)
- pattail
- Set tail pointer (from pattern.c pattail) - no-op in Rust AST model
- pattern_
range_ to_ string - Convert a pattern range to a string for display (from pattern.c pattern_range_to_string)
- pattry
- Try to match pattern against string
- pattrylen
- Try to match pattern against a length-limited string (from pattern.c pattrylen)
- pattryrefs
- Try to match with backreferences (from pattern.c pattryrefs)
- pattrystart
- Initialize pattern try (from pattern.c pattrystart) - no-op in Rust
- range_
type - Get the POSIX class type from name (from pattern.c range_type)
- restorepatterndisables
- Restore pattern disables state
- savepatterndisables
- Save pattern disables state
- startpatternscope
- Start a pattern scope (from pattern.c startpatternscope)