|
|
|
@ -5,7 +5,7 @@ import (
|
|
|
|
|
"slices"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const EPSILON int = 0xF0000
|
|
|
|
|
const epsilon int = 0xF0000
|
|
|
|
|
|
|
|
|
|
type assertType int
|
|
|
|
|
|
|
|
|
@ -276,7 +276,7 @@ func kleene(s1 nfaState) (*nfaState, error) {
|
|
|
|
|
|
|
|
|
|
toReturn := &nfaState{}
|
|
|
|
|
toReturn.transitions = make(map[int][]*nfaState)
|
|
|
|
|
toReturn.content = newContents(EPSILON)
|
|
|
|
|
toReturn.content = newContents(epsilon)
|
|
|
|
|
toReturn.isEmpty = true
|
|
|
|
|
toReturn.isKleene = true
|
|
|
|
|
toReturn.output = append(toReturn.output, toReturn)
|
|
|
|
@ -307,7 +307,7 @@ func alternate(s1 *nfaState, s2 *nfaState) *nfaState {
|
|
|
|
|
for _, c := range s2.content {
|
|
|
|
|
toReturn.transitions[c], _ = unique_append(toReturn.transitions[c], s2)
|
|
|
|
|
}
|
|
|
|
|
toReturn.content = newContents(EPSILON)
|
|
|
|
|
toReturn.content = newContents(epsilon)
|
|
|
|
|
toReturn.isEmpty = true
|
|
|
|
|
|
|
|
|
|
return toReturn
|
|
|
|
@ -316,7 +316,7 @@ func alternate(s1 *nfaState, s2 *nfaState) *nfaState {
|
|
|
|
|
func question(s1 *nfaState) *nfaState { // Use the fact that ab? == a(b|)
|
|
|
|
|
s2 := &nfaState{}
|
|
|
|
|
s2.transitions = make(map[int][]*nfaState)
|
|
|
|
|
s2.content = newContents(EPSILON)
|
|
|
|
|
s2.content = newContents(epsilon)
|
|
|
|
|
s2.output = append(s2.output, s2)
|
|
|
|
|
s2.isEmpty = true
|
|
|
|
|
s3 := alternate(s1, s2)
|
|
|
|
@ -341,7 +341,7 @@ func newState() nfaState {
|
|
|
|
|
// Creates and returns a state that _always_ has a zero-length match.
|
|
|
|
|
func zeroLengthMatchState() nfaState {
|
|
|
|
|
start := newState()
|
|
|
|
|
start.content = newContents(EPSILON)
|
|
|
|
|
start.content = newContents(epsilon)
|
|
|
|
|
start.isEmpty = true
|
|
|
|
|
start.assert = alwaysTrueAssert
|
|
|
|
|
return start
|
|
|
|
|