1. A method of translating a state machine into a state machine program comprising: identifying relationships between states, transitions and events in the state machine; generating a state machine program having a structure that operates in non-final states; and generating statements within the structure for detecting an event, evaluating the detected event based on a current state to identify if the current state is valid for the detected event, and determining a next state if the current state is valid.