|
|
|
@ -1065,7 +1065,7 @@ func thompson(re []postfixNode) (Reg, error) {
|
|
|
|
|
if c.endReps != -1 && c.endReps < c.startReps {
|
|
|
|
|
return Reg{}, fmt.Errorf("numeric specifier - start greater than end")
|
|
|
|
|
}
|
|
|
|
|
state := mustPop(&nfa)
|
|
|
|
|
poppedState := mustPop(&nfa)
|
|
|
|
|
var stateToAdd *State = nil
|
|
|
|
|
// Take advantage of the following facts:
|
|
|
|
|
// 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
|
|
|
|
|
// at this point, I can leave thompson untouched.
|
|
|
|
|
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
|
|
|
|
|
s2, err := kleene(*state)
|
|
|
|
|
s2, err := kleene(*poppedState)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return Reg{}, err
|
|
|
|
|
}
|
|
|
|
|
stateToAdd = concatenate(stateToAdd, s2)
|
|
|
|
|
} else { // Case 2
|
|
|
|
|
for i := c.startReps; i < c.endReps; i++ {
|
|
|
|
|
stateToAdd = concatenate(stateToAdd, question(cloneState(state)))
|
|
|
|
|
stateToAdd = concatenate(stateToAdd, question(cloneState(poppedState)))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nfa = append(nfa, stateToAdd)
|
|
|
|
|