Example #1
0
// NewWorld() setup HSM and all states for this C Comment Parsing example.
func NewWorld() *CCommentHSM {
	// setup the state machine with proper hierarchy
	top := hsm.NewTop()
	initial := hsm.NewInitial(top, StateCodeID)
	NewCodeState(top)
	NewSlashState(top)
	NewCommentState(top)
	NewStarState(top)
	sm := NewCCommentHSM(top, initial)
	// don't forget to initialize the hsm and all states.
	sm.Init()
	return sm
}
Example #2
0
func NewWorld() *AnnotatedHSM {
	top := hsm.NewTop()
	initial := hsm.NewInitial(top, StateS0ID)
	s0 := NewS0State(top)
	s1 := NewS1State(s0)
	NewS11State(s1)
	s2 := NewS2State(s0)
	s21 := NewS21State(s2)
	NewS211State(s21)
	sm := NewAnnotatedHSM(top, initial)
	sm.Init()
	return sm
}