Grammar transformation