Programming languages and compilers

What is the primary responsibility of a lexer in a compiler?