Renamed variable to avoid conflicting with type name

posixStyleMatching
Aadhavan Srinivasan 1 month ago
parent 7e88b8a4b0
commit 198a2c12a7

@ -1065,7 +1065,7 @@ func thompson(re []postfixNode) (Reg, error) {
if c.endReps != -1 && c.endReps < c.startReps { if c.endReps != -1 && c.endReps < c.startReps {
return Reg{}, fmt.Errorf("numeric specifier - start greater than end") return Reg{}, fmt.Errorf("numeric specifier - start greater than end")
} }
state := mustPop(&nfa) poppedState := mustPop(&nfa)
var stateToAdd *State = nil var stateToAdd *State = nil
// Take advantage of the following facts: // Take advantage of the following facts:
// a{5} == aaaaa // a{5} == aaaaa
@ -1080,17 +1080,17 @@ func thompson(re []postfixNode) (Reg, error) {
// b. Encode the logic while parsing the string (shunting-yard). If I can expand the numeric specifier // b. Encode the logic while parsing the string (shunting-yard). If I can expand the numeric specifier
// at this point, I can leave thompson untouched. // at this point, I can leave thompson untouched.
for i := 0; i < c.startReps; i++ { // Case 1 for i := 0; i < c.startReps; i++ { // Case 1
stateToAdd = concatenate(stateToAdd, cloneState(state)) stateToAdd = concatenate(stateToAdd, cloneState(poppedState))
} }
if c.endReps == infinite_reps { // Case 3 if c.endReps == infinite_reps { // Case 3
s2, err := kleene(*state) s2, err := kleene(*poppedState)
if err != nil { if err != nil {
return Reg{}, err return Reg{}, err
} }
stateToAdd = concatenate(stateToAdd, s2) stateToAdd = concatenate(stateToAdd, s2)
} else { // Case 2 } else { // Case 2
for i := c.startReps; i < c.endReps; i++ { for i := c.startReps; i < c.endReps; i++ {
stateToAdd = concatenate(stateToAdd, question(cloneState(state))) stateToAdd = concatenate(stateToAdd, question(cloneState(poppedState)))
} }
} }
nfa = append(nfa, stateToAdd) nfa = append(nfa, stateToAdd)

Loading…
Cancel
Save