Wrote toString function for MatchIndex

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

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

Loading…
Cancel
Save