refactor to use a functional parsers and generators.

clean up.

py3k only changes such as those to super(), integer division, annotations, placement of keyword/(double)star/normal args in function definitions and @lru_cache.