Rewrite Prism/PRE parsing logic