To answer your question, let me quote a part of Wikipedia entry for Discrete Mathematics concerning number theory.
Number theory is concerned with the properties of numbers in general,
particularly integers. (...) Other discrete aspects of number theory
include geometry of numbers. In analytic number theory, techniques
from continuous mathematics are also used. Topics that go beyond
discrete objects include transcendental numbers, diophantine
approximation, p-adic analysis and function fields.
I would say that the situation is similar for formal languages. Formal languages do belong to Discrete Mathematics, but some tools go beyond discrete objects.
Indeed, formal language theory makes use of topology, especially profinite topologies. See for instance the papers
Duality and equational theory of regular languages and
A Topological Approach to Recognition. By the way, this approach shares some analogy with the $p$-adic metric on the integers. For instance, the $p$-adic metric can be extended to words: see the paper (in French) Topologie $p$-adique sur les mots or Thue sequence and p-adic topology of the free monoid.