예제 #1
0
파일: dfa.go 프로젝트: pschlump/lexie
// -----------------------------------------------------------------------------------------------------------------------------------------------
func (dfa *DFA_PoolType) GetDFAName(StateSet []int) int {
	A := dfa.GetDFA()
	StateSet = com.USortIntSlice(StateSet) // Make set unique
	dfa.Pool[A].StateSet = StateSet
	dfa.Pool[A].StateName = com.NameOf(StateSet)
	dfa.Pool[A].Visited = false
	return A
}
예제 #2
0
파일: dfa.go 프로젝트: pschlump/lexie
// -----------------------------------------------------------------------------------------------------------------------------------------------
func (dfa *DFA_PoolType) HaveStateAlready(inputSet []int) (loc int) {
	// fmt.Printf("HaveStateAlready: >>>>>>>>>>>>>>>>>>>>>>> 0 inputSet: %s\n", com.SVar(inputSet))
	inputSet = com.USortIntSlice(inputSet) // Make set unique
	// fmt.Printf("HaveStateAlready: >>>>>>>>>>>>>>>>>>>>>>> 1 inputSet: %s\n", com.SVar(inputSet))
	s := com.NameOf(inputSet)
	// fmt.Printf("HaveStateAlready: >>>>>>>>>>>>>>>>>>>>>>> Name searcing for is: %s\n", s)
	for ii, vv := range dfa.Pool {
		//		if ii >= dfa.Cur || ii >= dfa.Top {
		//			fmt.Printf("   Reached break\n")
		//			break
		//		}
		if vv.IsUsed {
			// fmt.Printf(" ****** Checking for match between dfa.Pool[%d].StateName ->%s<- and ->%s<-\n", ii, vv.StateName, s)
			if vv.StateName == s {
				// fmt.Printf("   Match found at %d\n", ii)
				return ii
			}
		}
	}
	// fmt.Printf("    no Match found, returing -1\n")
	return -1
}