Hand-written Lexical Analyzer
A lexical analyzer can easily be written by hand. Typically, such a program will call functions getchar() and peekchar() to get characters from the input.
The lexical analyzer is likewise called as a function, with an entry such as gettoken(). The program is structured as:
Typically, a routine will process all tokens that look alike, e.g., all kinds of numbers, or both identifiers and reserved words.