Port Max's parser from the napkin