choosing terminals to save into grammar