Implement PCRE Matching (prefer left-branch) #2

Merged
Rockingcool merged 48 commits from implementPCREMatchingRules into master 2025-02-09 15:24:29 -06:00
6 changed files with 632 additions and 385 deletions
Showing only changes of commit 99230b49de - Show all commits

View File

@@ -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.
if len(re) == 0 {
start := zeroLengthMatchState()
nfa = append(nfa, &start)
nfa = append(nfa, start)
}
for _, c := range re {
@@ -1068,14 +1068,14 @@ func thompson(re []postfixNode) (Reg, error) {
nfa = append(nfa, s2)
}
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 { // See above for explanation
nfa = append(nfa, s1)
}
tmp := zeroLengthMatchState()
s1 = &tmp
s1 = tmp
}
s3 := alternate(s1, s2)
nfa = append(nfa, s3)