Implement NFA serialize/deserialize.