Software scanners are programs that analyze input characters or are used for security-related tasks that increase cyber security and detect and eliminate vulnerabilities in networks. As a security tool for system administration, software scanners can provide important information about the services operated, user IDs, access authorizations and authentications. Virus scanners, on the other hand, scan files for viruses.
Scanner in context with compilers
This reciprocal relationship is usually implemented in such a way that the scanner acts as a sub- or coroutine of the parser. Upon receiving a "pass next symbol" command given by the parser, the scanner reads input characters until it recognizes the next symbol.
The scanner is the part of the compiler that reads the source code. It is therefore obvious to assign further tasks to it with regard to the user interface. One of these tasks is to clean the source program from comments and spaces, tabs and line breaks. Another task is to assign the corresponding positions in the source program to the error messages of the compiler. For example, the scanner might remember the number of previous line breaks to assign an error message to a line number. In some compilers, the scanner must make a copy of the source program with error messages interspersed. If the source language provides functions of a macro processor, these functions may also be implemented as part of the lexical analysis.
Sometimes scanners are divided into two successive phases. The first phase does the pure reading of the input stream, the second does the actual lexical analysis. The tasks of the first phase are quite simple, while the more complex tasks are part of the second phase. One can imagine, for example, that in a compiler spaces in the input are removed by the read phase.