|
|
|
@ -828,9 +828,16 @@ func thompson(re []postfixNode) (Reg, error) {
|
|
|
|
|
switch c.nodetype {
|
|
|
|
|
case CONCATENATE:
|
|
|
|
|
s2 := mustPop(&nfa)
|
|
|
|
|
s1 := mustPop(&nfa)
|
|
|
|
|
// Relax the requirements for concatenation a little bit - If
|
|
|
|
|
// the second element is not found ie. the postfixNodes look
|
|
|
|
|
// like 'a~', then that's fine, we just skip the concatenation.
|
|
|
|
|
s1, err := pop(&nfa)
|
|
|
|
|
if err != nil {
|
|
|
|
|
nfa = append(nfa, s2)
|
|
|
|
|
} else {
|
|
|
|
|
s1 = concatenate(s1, s2)
|
|
|
|
|
nfa = append(nfa, s1)
|
|
|
|
|
}
|
|
|
|
|
case KLEENE: // Create a 0-state, concat the popped state after it, concat the 0-state after the popped state
|
|
|
|
|
s1 := mustPop(&nfa)
|
|
|
|
|
stateToAdd := kleene(*s1)
|
|
|
|
|