Factored grammar code into separate files: cfg and pcfg. TODO: improve pcfg.