refactor long methods in recursive descent parser