1. A computer-enabled system to provide a state machine for software program compilation, comprising: a microprocessor, a plurality of input events to one or more states in the state machine; a plurality of output events from the one or more states in the state machine; said one or more states, wherein a state in the one or more states is implemented in machine-independent bytecodes and is capable of: accepting and processing an input event in the plurality of input events; generating an output event in the plurality of output events; and switching to another state in the one or more states in the state machine, wherein the state in the one or more states has a multi-way branch that is capable of determining a next state to jump to from the state based on a value of a switch expression of a switch statement that is associated with the state, wherein the multi-way branch is implemented directly in byte code using a target array, wherein the indices of the target array represent the value of the switch expression of the multi-way branch and the entries of the target array represent the target locations of the next state.