In older languages such as ALGOL, the initial stage was instead line reconstruction, which performed unstropping and removed whitespace and comments (and had scannerless parsers, with no separate lexer).
Lexers and parsers are most often used for compilers, but can be used for other computer language tools, such as prettyprinters or linters.