2 Commits

3 changed files with 3 additions and 8 deletions

View File

@@ -176,7 +176,7 @@ func FindNthMatch(regex Reg, str string, n int) (Match, error) {
}
}
// We haven't found the nth match after scanning the string - Return an error
return nil, fmt.Errorf("Invalid match index. Too few matches found.")
return nil, fmt.Errorf("invalid match index - too few matches found")
}
// FindAllMatches tries to find all matches of the regex represented by given start-state, with

5
nfa.go
View File

@@ -205,11 +205,6 @@ func (s State) matchesFor(str []rune, idx int) ([]*State, int) {
return listTransitions, numTransitions
}
type NFA struct {
start State
outputs []State
}
// verifyLastStatesHelper performs the depth-first recursion needed for verifyLastStates
func verifyLastStatesHelper(state *State, visited map[*State]bool) {
if len(state.transitions) == 0 {

View File

@@ -5,7 +5,7 @@ import "errors"
// Helper functions for slices, to make them behave more like stacks
func peek[T any](s []T) (T, error) {
if len(s) < 1 {
return *new(T), errors.New("Stack empty")
return *new(T), errors.New("stack empty")
}
return s[len(s)-1], nil
}
@@ -20,7 +20,7 @@ func mustPop[T any](sp *[]T) T {
func pop[T any](sp *[]T) (T, error) {
if len(*sp) < 1 {
return *new(T), errors.New("Stack empty")
return *new(T), errors.New("stack empty")
}
to_return := (*sp)[len(*sp)-1]
*sp = (*sp)[:len(*sp)-1]