1. A method for performing semantic operations with contents of a message, comprising: receiving, at a processor, a message defined by message segments, wherein the message segments comprise packets in a packet-switched network; identifying a grammar associated with the message segments; converting the message segments into a token stream; creating a substructure from tokens of the token stream; identifying rules associated with the tokens, wherein the rules define actions for intrusion detection and prevention; associating each of the message segments with a meta session through the tokens, wherein the meta session is made persistent across message transactions by storing data generated by the meta session on a persistent storage medium; executing actions defined by the rules; and forwarding the message to a destination.