C++ implementation of the grammar extractor

A somewhat more detailed email will follow.