8. A computer-implemented method for generating a counting automaton for use by a field extractor, comprising: receiving an extraction specification that specifies data elements to be extracted from data packets and is expressed in terms of a context-free grammar, where the context-free grammar defines grammatical structures of data packets transmitted in accordance with an application protocol and is defined as a tuple having nonterminals, terminals, counters, production rules and a start nonterminal, such that the counters are variable with an integer value used to chronicle parsing history of the production rules and at least one of the production rules includes an action association with a terminal or nonterminal comprising body of the production rule and the action is an expression for updating a value of a counter defined by the grammar; transforming the extraction specification to an equivalent regular grammar; and generating a counting automaton from the regular grammar.
10. The method of claim 8 wherein the production rules are in the form of <predicate>: <nonterminal>→<body>, such that the body is an ordered sequence of terminals and nonterminals and each predicate is expressed in terms of at least one counter.