|
|
|
@ -15,6 +15,12 @@ var LPAREN_CHAR rune = 0xF0004 // Parentheses in regex are concatenated with thi
|
|
|
|
|
var RPAREN_CHAR rune = 0xF0005
|
|
|
|
|
var NONCAPLPAREN_CHAR rune = 0xF0006 // Represents a non-capturing group's LPAREN
|
|
|
|
|
var ESC_BACKSLASH rune = 0xF0007 // Represents an escaped backslash
|
|
|
|
|
var CHAR_RANGE rune = 0xF0008 // Represents a character range
|
|
|
|
|
|
|
|
|
|
// An interface for int and rune, which are identical
|
|
|
|
|
type character interface {
|
|
|
|
|
int | rune
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns true if str[idx] and str[idx-1] are separated by a word boundary.
|
|
|
|
|
func isWordBoundary(str []rune, idx int) bool {
|
|
|
|
@ -109,8 +115,8 @@ func Reduce[T any](slc []T, fn func(T, T) T) T {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate numbers in a range - start (inclusive) to end (exclusive)
|
|
|
|
|
func genRange(start, end int) []int {
|
|
|
|
|
toRet := make([]int, end-start)
|
|
|
|
|
func genRange[T character](start, end T) []T {
|
|
|
|
|
toRet := make([]T, end-start)
|
|
|
|
|
for i := start; i < end; i++ {
|
|
|
|
|
toRet[i-start] = i
|
|
|
|
|
}
|
|
|
|
|