Wrote toString function for MatchIndex

master
Aadhavan Srinivasan 1 month ago
parent 160b2f9215
commit 2569f52552

@ -1,6 +1,9 @@
package main
import "sort"
import (
"fmt"
"sort"
)
// a MatchIndex represents a match/group. It contains the start index and end index of the match
type MatchIndex struct {
@ -8,10 +11,10 @@ type MatchIndex struct {
endIdx int
}
// A Match represents multiple matchIndices. Specifically, it maps an integer (representing the capturing group)
// to the matchIndex of that group.
// Group 0 corresponds to the entire match.
type Match map[int]MatchIndex
// Converts the MatchIndex into a string representation:
func (idx MatchIndex) toString() string {
return fmt.Sprintf("%d\t%d", idx.startIdx, idx.endIdx)
}
// takeZeroState takes the 0-state (if such a transition exists) for all states in the
// given slice. It returns the resulting states. If any of the resulting states is a 0-state,

Loading…
Cancel
Save