Linguistic typology and formal grammar