Rewrite parser to have side-effect-free actions