1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! # `nytri` ("n-eye-tree") — Not Your Typical Regex Implementation
//!
//! `nytri` is a low-level Regular Expressions library with a focus on user-control.
//!
//! What does this mean? In practice, it means that `nytri` is designe to provide its users an unusual
//! level of access to the underlying Regex engine. Things like:
//!
//! * Stateful matching — i.e. feeding pieces of a match piece-by-piece
//! * Saving & restoring match state
//! * ... and many more planned.
//!
//! **This library is under initial development.** It should not be used in any serious setting, and
//! does not yet come close to the feature set that should be expected by a quality regex
//! implementation.
//!
//! ## Current & Planned features
//!
//! Before reading this list, note: `nytri` will always guarantee linear-time matching. Because of this,
//! some features are not possible to implement fully (like backreferences).
//!
//! Current:
//!
//! * [x] (very) Basic full-text matching (grouping w/ parens, alternatives, literals)
//! * [x] Stateful matching (via `Matcher::feed` & `Matcher::is_match`)
//! * [x] Matcher state save & restore (via `Matcher::get_state` & `Matcher::from_state`)
//!
//! Planned:
//!
//! * [ ] Error display options & configuration
//! * [ ] Syntax:
//! * [ ] All of: `.`, `*`, `+`, and `?` — with the standard meanings.
//! * [ ] Character escapes
//! * [ ] (ASCII) Character classes
//! * [ ] Unicode character classes
//! * [ ] Matcher configuration — will be clarified in the future
//! * [ ] Extracting capture groups (Named and unnamed)
//! * [ ] Possible: intentionally don't capture certain groups, for efficiency.
//! * [ ] Possessive capture groups
//! * [ ] Lookahead & lookbehind (plus their negative variants)
//! * [ ] Generic atom and text types (e.g. alternatives to `char` and `&str`, or matching on `&[u8]`
//! implemented as "just another text type")
//! * [ ] Limited support for backreferences (there is a useful subset that can be matched in linear-time)
pub use ;
use Nfa;
use Borrow;
/// A compiled regex
/// A match-searching object, referencing a compiled [`Regex`]
///
/// By default, this type refers to an owned `Regex`, but a generic type can be provided to change
/// the type of reference to the `Regex`. The [`MatcherRef`] type is provided for your convenience.
///
/// Typically, instances of this type are constructed with the [`matcher`] method on `Regex`. You
/// can also use [`Matcher::new`] to use any reference type (implementing `Borrow<Regex>`).
///
/// [`matcher`]: Regex::matcher
/// [`matcher_ref`]: Regex::matcher_ref
/// A match-searching object, referencing a compiled [`Regex`]
///
/// Returned by [`Regex::matcher`].
///
/// This alias is typically preferred in the "standard" usage pattern — i.e. when the input is
/// completely known beforehand or control is not yielded during matching. This is how most regex
/// libraries expose their interface, and the `MatcherRef` borrows the underlying compiled regex to
/// accomodate this.
///
/// However, `Matcher`s are stateful & control can be yielded between providing input. Using a
/// `MatcherRef` with this pattern can make lifetime management tricky — in these cases, using a
/// plain [`Matcher`] (either owning the `Regex` directly, or with `Rc`/`Arc`) is often much
/// simpler.
pub type MatcherRef<'re> = ;
/// The saved state of a matcher, available for comparison or restoration
/// Helper type for granting access to the underlying NFA from arbitrary reference types