Reverse the order in which I pop states for alternation, because this messes with the left branch-right branch thing

This commit is contained in:
2025-02-03 21:59:41 -05:00
parent de0d7345a8
commit 5563a70568

View File

@@ -1059,8 +1059,8 @@ func thompson(re []postfixNode) (Reg, error) {
// '|a'
// '^a|'
// '^|a'
s1, err1 := pop(&nfa)
s2, err2 := pop(&nfa)
s2, err1 := pop(&nfa)
s1, err2 := pop(&nfa)
if err2 != nil || (s2.groupBegin && len(s2.transitions) == 0) { // Doesn't exist, or its just an LPAREN
if err2 == nil { // Roundabout way of saying that this node existed, but it was an LPAREN, so we append it back
nfa = append(nfa, s2)