From a259f0ceabc5a82b05b09f87868e62d6fa90f97b Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sat, 25 Jan 2025 22:35:52 -0500 Subject: [PATCH] Created a function to return a state that will always have a zero-length state --- nfa.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nfa.go b/nfa.go index 0d45cfa..66b09ce 100644 --- a/nfa.go +++ b/nfa.go @@ -333,3 +333,12 @@ func newState() State { ret.output = append(ret.output, &ret) return ret } + +// Creates and returns a state that _always_ has a zero-length match. +func zeroLengthMatchState() State { + start := newState() + start.content = newContents(EPSILON) + start.isEmpty = true + start.assert = ALWAYS_TRUE + return start +}