Created function that returns a 'default' state
This commit is contained in:
17
nfa.go
17
nfa.go
@@ -136,7 +136,7 @@ func (s State) checkAssertion(str []rune, idx int) bool {
|
|||||||
strToMatch = string(runesToMatch)
|
strToMatch = string(runesToMatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
matchIndices := findAllMatches(Reg{startState, s.lookaroundNumCaptureGroups}, strToMatch)
|
matchIndices := FindAllMatches(Reg{startState, s.lookaroundNumCaptureGroups}, strToMatch)
|
||||||
|
|
||||||
numMatchesFound := 0
|
numMatchesFound := 0
|
||||||
for _, matchIdx := range matchIndices {
|
for _, matchIdx := range matchIndices {
|
||||||
@@ -314,3 +314,18 @@ func question(s1 *State) *State { // Use the fact that ab? == a(b|)
|
|||||||
s3 := alternate(s1, s2)
|
s3 := alternate(s1, s2)
|
||||||
return s3
|
return s3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates and returns a new state with the 'default' values.
|
||||||
|
func newState() State {
|
||||||
|
ret := State{
|
||||||
|
output: make([]*State, 0),
|
||||||
|
transitions: make(map[int][]*State),
|
||||||
|
assert: NONE,
|
||||||
|
except: append([]rune{}, 0),
|
||||||
|
lookaroundRegex: "",
|
||||||
|
groupEnd: false,
|
||||||
|
groupBegin: false,
|
||||||
|
}
|
||||||
|
ret.output = append(ret.output, &ret)
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user