|
|
|
@ -11,8 +11,10 @@ type assertType int
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
noneAssert assertType = iota
|
|
|
|
|
sosAssert
|
|
|
|
|
eosAssert
|
|
|
|
|
sosAssert // Start of string (^)
|
|
|
|
|
soiAssert // Start of input (\A)
|
|
|
|
|
eosAssert // End of string ($)
|
|
|
|
|
eoiAssert // End of input (\Z)
|
|
|
|
|
wboundAssert
|
|
|
|
|
nonwboundAssert
|
|
|
|
|
plaAssert // Positive lookahead
|
|
|
|
@ -119,6 +121,15 @@ func (s nfaState) checkAssertion(str []rune, idx int) bool {
|
|
|
|
|
// Index is at the end of the string, or it points to the last character which is a newline
|
|
|
|
|
return idx == len(str) || (multilineMode && str[idx] == '\n')
|
|
|
|
|
}
|
|
|
|
|
if s.assert == soiAssert {
|
|
|
|
|
// Only true at the start of the input, regardless of mode
|
|
|
|
|
return idx == 0
|
|
|
|
|
}
|
|
|
|
|
if s.assert == eoiAssert {
|
|
|
|
|
// Only true at the end of the input, regardless of mode
|
|
|
|
|
return idx == len(str)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if s.assert == wboundAssert {
|
|
|
|
|
return isWordBoundary(str, idx)
|
|
|
|
|
}
|
|
|
|
|