1. A computer-implemented method of translating a state machine into an executable state machine program, the method comprising: determining states and transitions in a state machine; generating a first structure representing the state machine by associating events in the state machine with the determined states and transitions; generating an executable state machine program having a second structure that operates in non-final states; and generating statements within the second 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; and wherein the step of generating a first structure comprises: determining all events in the state machine; correlating the events with states in the state machine; and correlating the event correlated states with transitions in the state machine to form the first structure.