The present invention generates state machines that can be used in a
scanner and/or a parser for software program compilation. The state
machines are not table-driven, but rather are encoded directly by
creating jumps and branches in bytecodes, which are machine-independent
codes generated by a Java compiler and can be executed on any
Java-enabled device. Such state machines can be much faster than those
based on tables, and much smaller in code size than those implemented in
executable codes. In addition, such state machines can be optimized to
reduce the number of states and the amount of codes required to encode
each state in it. This can allow these state machines to meet strict code
size restrictions specified by certain virtual machines, such as the Java
virtual machine.