Towards an integrated theory of formal and natural languages