Rewrite parser in java