Module
sysl.regex
max_program char_class compile compile_pattern describe dump exec exec_from named_class parse parse_counted regex show CharClass CharRange Inst Match NamedClass Node Program Regex RegexError
Import
import sysl.regex
Index
max_program char_class compile compile_pattern describe dump exec exec_from named_class parse parse_counted regex show CharClass CharRange Inst Match NamedClass Node Program Regex RegexError
Constants
max_program
const max_program: u32 = 100000
Functions
char_class
char_class() -> CharClass
compile
compile(root: &Node, groups: int) -> Result[Program, RegexError]
compile_pattern
compile_pattern(pattern: string) -> Result[Program, RegexError]
describe
describe(e: RegexError) -> string
dump
dump(p: Program) -> string
exec
exec(prog: Program, input: string) -> Option[[]int]
exec_from
exec_from(prog: Program, input: string, from: usize) -> Option[[]int]
named_class
named_class(name: string) -> Option[NamedClass]
parse
parse(pattern: string) -> Result[&Node, RegexError]
parse_counted
parse_counted(pattern: string) -> Result[(&Node, int), RegexError]
regex
regex(pattern: string) -> Result[Regex, RegexError]
show
show(n: &Node) -> string
Types
CharClass
struct CharClass
ranges: &Buf[CharRange]
names: &Buf[NamedClass]
negated: bool
| Member | Signature | Description |
|---|---|---|
admits | admits(self, c: char) -> bool |
CharRange
struct CharRange
lo: u32
hi: u32
Inst
enum Inst
MatchChar(ch: char)
MatchAny
MatchSet(of: CharClass)
Accept
Jump(to: usize)
Split(first: usize, second: usize)
Save(slot: usize)
AssertStart
AssertEnd
Match
struct Match
src: string
slots: []int
| Member | Signature | Description |
|---|---|---|
group_count | group_count(self) -> usize | |
span | span(self, i: usize) -> Option[(usize, usize)] | |
group | group(self, i: usize) -> Option[string] | |
text | text(self) -> string | |
start | start(self) -> usize | |
end | end(self) -> usize |
NamedClass
enum NamedClass
Alpha
Digit
Alnum
Upper
Lower
Space
Blank
Print
Graph
Cntrl
Punct
XDigit
Node
enum Node
Empty
Lit(ch: char)
AnyChar
AtStart
AtEnd
InSet(of: CharClass)
Seq(left: &Node, right: &Node)
Alt(left: &Node, right: &Node)
Star(inner: &Node)
Plus(inner: &Node)
Quest(inner: &Node)
Group(inner: &Node, index: int)
Program
struct Program
code: &Buf[Inst]
groups: int
over: bool
| Member | Signature | Description |
|---|---|---|
len | len(self) -> usize | |
at | at(self, pc: usize) -> Inst | |
slots | slots(self) -> usize | |
emit | emit(*self, i: Inst) -> usize | |
patch | patch(*self, pc: usize, i: Inst) |
Regex
struct Regex
pattern: string
prog: Program
| Member | Signature | Description |
|---|---|---|
group_count | group_count(self) -> int | |
find | find(self, s: string) -> Option[Match] | |
find_at | find_at(self, s: string, from: usize) -> Option[Match] | |
is_match | is_match(self, s: string) -> bool | |
find_all | find_all(self, s: string) -> &Buf[Match] | |
replace_all | replace_all(self, s: string, with: string) -> string | |
split | split(self, s: string) -> &Buf[string] |
RegexError
enum RegexError
TrailingBackslash(at: usize)
UnterminatedClass(at: usize)
UnterminatedClassName(at: usize)
UnknownClassName(at: usize, name: string)
UnterminatedGroup(at: usize)
UnmatchedParen(at: usize)
UnterminatedInterval(at: usize)
MissingIntervalCount(at: usize)
BackwardsInterval(at: usize)
BackwardsRange(at: usize)
NothingToRepeat(at: usize)
PatternTooLarge