|
|
|
@ -73,7 +73,7 @@ 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 string, idx int) bool {
|
|
|
|
|
func (s State) checkAssertion(str []rune, idx int) bool {
|
|
|
|
|
if s.assert == SOS {
|
|
|
|
|
return idx == 0
|
|
|
|
|
}
|
|
|
|
@ -90,7 +90,7 @@ func (s State) checkAssertion(str string, idx int) bool {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns true if the contents of 's' contain the value at the given index of the given string
|
|
|
|
|
func (s State) contentContains(str string, idx int) bool {
|
|
|
|
|
func (s State) contentContains(str []rune, idx int) bool {
|
|
|
|
|
if s.assert != NONE {
|
|
|
|
|
return s.checkAssertion(str, idx)
|
|
|
|
|
}
|
|
|
|
@ -100,7 +100,7 @@ func (s State) contentContains(str string, idx int) bool {
|
|
|
|
|
|
|
|
|
|
// Returns the matches for the character at the given index of the given string.
|
|
|
|
|
// Also returns the number of matches. Returns -1 if an assertion failed.
|
|
|
|
|
func (s State) matchesFor(str string, idx int) ([]*State, int) {
|
|
|
|
|
func (s State) matchesFor(str []rune, idx int) ([]*State, int) {
|
|
|
|
|
// Assertions can be viewed as 'checks'. If the check fails, we return
|
|
|
|
|
// an empty array and 0.
|
|
|
|
|
// If it passes, we treat it like any other state, and return all the transitions.
|
|
|
|
|