Added new assertion that always evaluates to true
This commit is contained in:
12
nfa.go
12
nfa.go
@@ -14,10 +14,11 @@ const (
|
|||||||
EOS
|
EOS
|
||||||
WBOUND
|
WBOUND
|
||||||
NONWBOUND
|
NONWBOUND
|
||||||
PLA // Positive lookahead
|
PLA // Positive lookahead
|
||||||
NLA // Negative lookahead
|
NLA // Negative lookahead
|
||||||
PLB // Positive lookbehind
|
PLB // Positive lookbehind
|
||||||
NLB // Negative lookbehind
|
NLB // Negative lookbehind
|
||||||
|
ALWAYS_TRUE // An assertion that is always true
|
||||||
)
|
)
|
||||||
|
|
||||||
type State struct {
|
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
|
// Checks if the given state's assertion is true. Returns true if the given
|
||||||
// state doesn't have an assertion.
|
// state doesn't have an assertion.
|
||||||
func (s State) checkAssertion(str []rune, idx int) bool {
|
func (s State) checkAssertion(str []rune, idx int) bool {
|
||||||
|
if s.assert == ALWAYS_TRUE {
|
||||||
|
return true
|
||||||
|
}
|
||||||
if s.assert == SOS {
|
if s.assert == SOS {
|
||||||
return idx == 0
|
return idx == 0
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user