A packet classification language (GPCL) is provided to specify protocol
hierarchies among data packets in a routing device. The GPCL uses regular
expressions to match incoming data packets and a syntax to describe the
protocol hierarchy. A GPCL compiler produces an enhanced DFA which
incorporates the regular expression for recognizing constituent parts of
a data packets and which incorporates the grammar graph defining the
relationships among the constituent parts. A hardware implemented DFA is
used to scan the input stream which constitutes the data packets.