Implement PCRE Matching (prefer left-branch) #2
@@ -816,7 +816,7 @@ func thompson(re []postfixNode) (Reg, error) {
|
|||||||
// In these cases, we will return an NFA with 1 state, with an assertion that is always true.
|
// In these cases, we will return an NFA with 1 state, with an assertion that is always true.
|
||||||
if len(re) == 0 {
|
if len(re) == 0 {
|
||||||
start := zeroLengthMatchState()
|
start := zeroLengthMatchState()
|
||||||
nfa = append(nfa, &start)
|
nfa = append(nfa, start)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range re {
|
for _, c := range re {
|
||||||
@@ -1068,14 +1068,14 @@ func thompson(re []postfixNode) (Reg, error) {
|
|||||||
nfa = append(nfa, s2)
|
nfa = append(nfa, s2)
|
||||||
}
|
}
|
||||||
tmp := zeroLengthMatchState()
|
tmp := zeroLengthMatchState()
|
||||||
s2 = &tmp
|
s2 = tmp
|
||||||
}
|
}
|
||||||
if err1 != nil || (s1.groupBegin && s1.numTransitions() == 0) { // Doesn't exist, or its just an LPAREN
|
if err1 != nil || (s1.groupBegin && s1.numTransitions() == 0) { // Doesn't exist, or its just an LPAREN
|
||||||
if err1 == nil { // See above for explanation
|
if err1 == nil { // See above for explanation
|
||||||
nfa = append(nfa, s1)
|
nfa = append(nfa, s1)
|
||||||
}
|
}
|
||||||
tmp := zeroLengthMatchState()
|
tmp := zeroLengthMatchState()
|
||||||
s1 = &tmp
|
s1 = tmp
|
||||||
}
|
}
|
||||||
s3 := alternate(s1, s2)
|
s3 := alternate(s1, s2)
|
||||||
nfa = append(nfa, s3)
|
nfa = append(nfa, s3)
|
||||||
|
Reference in New Issue
Block a user