Adds prefix tree for faster grammar lookup