split parser generation into its own function