Remove repeated code.
Convert pattern and type parsers to Pratt parsers.