Add Packrat-inspired caching.

On a 11000-line MysoreScript file, the parsing time drops from 31 seconds to 0.4 seconds (release / optimised build), at the cost of peak memory usage (for the whole program, not just Pegmatite) increasing from about 26MB to 31MB.