File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -135,15 +135,21 @@ class QRegex::NFA {
135
135
my $ subrule := $ cursor . HOW . find_method($ cursor , $ name );
136
136
my @ substates := $ subrule . nqpattr(' nfa' ) if $ subrule ;
137
137
if @ substates {
138
- # append a clone of the new states to our states
139
- my $ substart := nqp :: elems ($ ! states );
140
- for @ substates { nqp :: push ($ ! states , nqp :: clone ($ _ )) }
141
- my $ subend := nqp :: elems ($ ! states );
138
+ # create an empty end state for the subrule's NFA
139
+ my $ substart := self . addstate();
140
+ # Copy (yes, clone) @substates[1..*] into our states.
141
+ # We have to clone because we'll be modifying the
142
+ # values for use in this particular NFA.
143
+ @ substates := nqp :: clone (@ substates );
144
+ nqp :: shift (@ substates );
145
+ nqp :: push ($ ! states , nqp :: clone (nqp :: shift (@ substates )))
146
+ while @ substates ;
142
147
# Go through all of the newly added states, and
143
148
# apply $substart offset to target states
144
149
# adjust fate edges to be $fate
145
150
# append any subrules
146
- my $ i := $ substart ;
151
+ my $ subend := nqp :: elems ($ ! states );
152
+ my $ i := $ substart ;
147
153
while $ i < $ subend {
148
154
my $ substate := $ ! states [$ i ];
149
155
my $ j := 0 ;
You can’t perform that action at this time.
0 commit comments