|
|
@ -1,6 +1,7 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"slices"
|
|
|
|
"slices"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -268,7 +269,11 @@ func concatenate(s1 *State, s2 *State) *State {
|
|
|
|
return s1
|
|
|
|
return s1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func kleene(s1 State) *State {
|
|
|
|
func kleene(s1 State) (*State, error) {
|
|
|
|
|
|
|
|
if s1.isEmpty && s1.assert != NONE {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("previous token is not quantifiable")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toReturn := &State{}
|
|
|
|
toReturn := &State{}
|
|
|
|
toReturn.transitions = make(map[int][]*State)
|
|
|
|
toReturn.transitions = make(map[int][]*State)
|
|
|
|
toReturn.content = newContents(EPSILON)
|
|
|
|
toReturn.content = newContents(EPSILON)
|
|
|
@ -283,7 +288,7 @@ func kleene(s1 State) *State {
|
|
|
|
for _, c := range s1.content {
|
|
|
|
for _, c := range s1.content {
|
|
|
|
toReturn.transitions[c], _ = unique_append(toReturn.transitions[c], &s1)
|
|
|
|
toReturn.transitions[c], _ = unique_append(toReturn.transitions[c], &s1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return toReturn
|
|
|
|
return toReturn, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func alternate(s1 *State, s2 *State) *State {
|
|
|
|
func alternate(s1 *State, s2 *State) *State {
|
|
|
|