Loosened restrictions for concatenation - It's okay if one of the
elements is missing
This commit is contained in:
13
compile.go
13
compile.go
@@ -828,9 +828,16 @@ func thompson(re []postfixNode) (Reg, error) {
|
||||
switch c.nodetype {
|
||||
case CONCATENATE:
|
||||
s2 := mustPop(&nfa)
|
||||
s1 := mustPop(&nfa)
|
||||
s1 = concatenate(s1, s2)
|
||||
nfa = append(nfa, s1)
|
||||
// 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)
|
||||
|
Reference in New Issue
Block a user