@@ -41,9 +41,7 @@ enum State {
4141 } ,
4242 /// A state that only transitions to another state if the current input
4343 /// byte is in a particular range of bytes.
44- ByteRange {
45- trans : Transition ,
46- } ,
44+ ByteRange { trans : Transition } ,
4745 /// A state with possibly many transitions, represented in a sparse
4846 /// fashion. Transitions must be ordered lexicographically by input range
4947 /// and be non-overlapping. As such, this may only be used when every
@@ -57,15 +55,10 @@ enum State {
5755 /// that `Sparse` is used for via `Union`. But this creates a more bloated
5856 /// NFA with more epsilon transitions than is necessary in the special case
5957 /// of character classes.
60- Sparse {
61- transitions : Vec < Transition > ,
62- } ,
58+ Sparse { transitions : Vec < Transition > } ,
6359 /// A conditional epsilon transition satisfied via some sort of
6460 /// look-around.
65- Look {
66- look : Look ,
67- next : StateID ,
68- } ,
61+ Look { look : Look , next : StateID } ,
6962 /// An empty state that records the start of a capture location. This is an
7063 /// unconditional epsilon transition like `Empty`, except it can be used to
7164 /// record position information for a capture group when using the NFA for
@@ -98,20 +91,21 @@ enum State {
9891 /// The next state that this state should transition to.
9992 next : StateID ,
10093 } ,
101- WriteLookaround {
102- lookaround_index : usize ,
103- } ,
94+ /// An empty state that behaves analogously to a `Match` state but for
95+ /// the look-around sub-expression with the given index.
96+ WriteLookaround { lookaround_index : SmallIndex } ,
97+ /// A conditional epsilon transition that will only be taken if the
98+ /// look-around sub-expression with the given index evaluates to `positive`
99+ /// at the current position in the haystack.
104100 CheckLookaround {
105- lookaround_index : usize ,
101+ lookaround_index : SmallIndex ,
106102 positive : bool ,
107103 next : StateID ,
108104 } ,
109105 /// An alternation such that there exists an epsilon transition to all
110106 /// states in `alternates`, where matches found via earlier transitions
111107 /// are preferred over later transitions.
112- Union {
113- alternates : Vec < StateID > ,
114- } ,
108+ Union { alternates : Vec < StateID > } ,
115109 /// An alternation such that there exists an epsilon transition to all
116110 /// states in `alternates`, where matches found via later transitions are
117111 /// preferred over earlier transitions.
@@ -127,9 +121,7 @@ enum State {
127121 /// to be amortized constant time. But if we used a `Union`, we'd need to
128122 /// prepend the state, which takes O(n) time. There are other approaches we
129123 /// could use to solve this, but this seems simple enough.
130- UnionReverse {
131- alternates : Vec < StateID > ,
132- } ,
124+ UnionReverse { alternates : Vec < StateID > } ,
133125 /// A state that cannot be transitioned out of. This is useful for cases
134126 /// where you want to prevent matching from occurring. For example, if your
135127 /// regex parser permits empty character classes, then one could choose a
@@ -143,9 +135,7 @@ enum State {
143135 ///
144136 /// `pattern_id` refers to the ID of the pattern itself, which corresponds
145137 /// to the pattern's index (starting at 0).
146- Match {
147- pattern_id : PatternID ,
148- } ,
138+ Match { pattern_id : PatternID } ,
149139}
150140
151141impl State {
@@ -736,7 +726,7 @@ impl Builder {
736726 /// is satisfied at the current position.
737727 pub fn add_write_lookaround (
738728 & mut self ,
739- index : usize ,
729+ index : SmallIndex ,
740730 ) -> Result < StateID , BuildError > {
741731 self . add ( State :: WriteLookaround { lookaround_index : index } )
742732 }
@@ -745,7 +735,7 @@ impl Builder {
745735 /// index is satisfied at the current position.
746736 pub fn add_check_lookaround (
747737 & mut self ,
748- index : usize ,
738+ index : SmallIndex ,
749739 positive : bool ,
750740 next : StateID ,
751741 ) -> Result < StateID , BuildError > {
0 commit comments