1. A system to provide a state machine for software program compilation, comprising: 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 bytecodes in Java 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 anther state in the one or more states in the state machine based on the value of a switch expression.