From 4dfc77900fc1eba197058be1bc505baccb6d496e Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sat, 25 Jan 2025 13:04:51 -0500 Subject: [PATCH] Added new assertion that always evaluates to true --- nfa.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nfa.go b/nfa.go index 5d1a4a4..0d45cfa 100644 --- a/nfa.go +++ b/nfa.go @@ -14,10 +14,11 @@ const ( EOS WBOUND NONWBOUND - PLA // Positive lookahead - NLA // Negative lookahead - PLB // Positive lookbehind - NLB // Negative lookbehind + PLA // Positive lookahead + NLA // Negative lookahead + PLB // Positive lookbehind + NLB // Negative lookbehind + ALWAYS_TRUE // An assertion that is always true ) type State struct { @@ -103,6 +104,9 @@ func cloneStateHelper(state *State, cloneMap map[*State]*State) *State { // Checks if the given state's assertion is true. Returns true if the given // state doesn't have an assertion. func (s State) checkAssertion(str []rune, idx int) bool { + if s.assert == ALWAYS_TRUE { + return true + } if s.assert == SOS { return idx == 0 }